BuildResourceMetadataURL constructs the full URL to the OAuth protected resource metadata endpoint.
(r *http.Request, cfg *Config, resourcePath string)
| 247 | |
| 248 | // BuildResourceMetadataURL constructs the full URL to the OAuth protected resource metadata endpoint. |
| 249 | func BuildResourceMetadataURL(r *http.Request, cfg *Config, resourcePath string) string { |
| 250 | host, scheme := GetEffectiveHostAndScheme(r, cfg) |
| 251 | suffix := "" |
| 252 | if resourcePath != "" && resourcePath != "/" { |
| 253 | if !strings.HasPrefix(resourcePath, "/") { |
| 254 | suffix = "/" + resourcePath |
| 255 | } else { |
| 256 | suffix = resourcePath |
| 257 | } |
| 258 | } |
| 259 | if cfg != nil && cfg.BaseURL != "" { |
| 260 | return strings.TrimSuffix(cfg.BaseURL, "/") + OAuthProtectedResourcePrefix + suffix |
| 261 | } |
| 262 | return fmt.Sprintf("%s://%s%s%s", scheme, host, OAuthProtectedResourcePrefix, suffix) |
| 263 | } |
| 264 | |
| 265 | func normalizeBasePath(path string) string { |
| 266 | trimmed := strings.TrimSpace(path) |