buildResourceURL constructs the full resource URL for OAuth metadata.
(r *http.Request, resourcePath string)
| 196 | |
| 197 | // buildResourceURL constructs the full resource URL for OAuth metadata. |
| 198 | func (h *AuthHandler) buildResourceURL(r *http.Request, resourcePath string) string { |
| 199 | host, scheme := GetEffectiveHostAndScheme(r, h.cfg) |
| 200 | baseURL := fmt.Sprintf("%s://%s", scheme, host) |
| 201 | if h.cfg.BaseURL != "" { |
| 202 | baseURL = strings.TrimSuffix(h.cfg.BaseURL, "/") |
| 203 | } |
| 204 | if resourcePath == "" { |
| 205 | resourcePath = "/" |
| 206 | } |
| 207 | if !strings.HasPrefix(resourcePath, "/") { |
| 208 | resourcePath = "/" + resourcePath |
| 209 | } |
| 210 | return baseURL + resourcePath |
| 211 | } |
| 212 | |
| 213 | // GetEffectiveHostAndScheme returns the effective host and scheme for a request. |
| 214 | // |
no test coverage detected