routesForPattern generates route variants for a given pattern. GitHub strips the /mcp prefix before forwarding, so we register both variants: - With /mcp prefix: for direct access or when GitHub doesn't strip - Without /mcp prefix: for when GitHub has stripped the prefix
(pattern string)
| 149 | // - With /mcp prefix: for direct access or when GitHub doesn't strip |
| 150 | // - Without /mcp prefix: for when GitHub has stripped the prefix |
| 151 | func (h *AuthHandler) routesForPattern(pattern string) []string { |
| 152 | basePaths := []string{""} |
| 153 | if basePath := normalizeBasePath(h.cfg.ResourcePath); basePath != "" { |
| 154 | basePaths = append(basePaths, basePath) |
| 155 | } else { |
| 156 | basePaths = append(basePaths, "/mcp") |
| 157 | } |
| 158 | |
| 159 | routes := make([]string, 0, len(basePaths)*2) |
| 160 | for _, basePath := range basePaths { |
| 161 | routes = append(routes, joinRoute(basePath, pattern)) |
| 162 | routes = append(routes, joinRoute(basePath, pattern)+"/") |
| 163 | } |
| 164 | |
| 165 | return routes |
| 166 | } |
| 167 | |
| 168 | // resolveResourcePath returns the externally visible resource path, |
| 169 | // restoring the configured base path when proxies strip it before forwarding. |
no test coverage detected