composeURL combines the configured upstream URL with the per-request path. The upstream URL typically already includes the canonical path (e.g. https://api.openai.com/v1/chat/completions) so the per-request path is ignored in that case. When upstream_url is a bare host (https://api.openai.com), the
(upstream, reqPath string)
| 395 | // path is ignored in that case. When upstream_url is a bare host |
| 396 | // (https://api.openai.com), the request path is appended. |
| 397 | func composeURL(upstream, reqPath string) (string, error) { |
| 398 | u, err := url.Parse(upstream) |
| 399 | if err != nil { |
| 400 | return "", fmt.Errorf("cloud-proxy: parse upstream_url %q: %w", upstream, err) |
| 401 | } |
| 402 | if u.Path == "" || u.Path == "/" { |
| 403 | u.Path = reqPath |
| 404 | } |
| 405 | return u.String(), nil |
| 406 | } |
| 407 | |
| 408 | // applyAuthHeader writes the appropriate authorization header for the |
| 409 | // provider. OpenAI/Anthropic/most providers use Bearer; Anthropic |
no test coverage detected