(ctx context.Context)
| 314 | } |
| 315 | |
| 316 | func (a *Adapter) Health(ctx context.Context) error { |
| 317 | if a.isAzure() { |
| 318 | return a.healthAzure(ctx) |
| 319 | } |
| 320 | path := strings.TrimSpace(a.cfg.HealthPath) |
| 321 | if path == "" { |
| 322 | path = "/health" |
| 323 | } |
| 324 | if !strings.HasPrefix(path, "/") { |
| 325 | path = "/" + path |
| 326 | } |
| 327 | u := joinURL(a.cfg.Endpoint, path) |
| 328 | httpReq, err := http.NewRequestWithContext(ctx, http.MethodGet, u, nil) |
| 329 | if err != nil { |
| 330 | return err |
| 331 | } |
| 332 | a.applyHeaders(httpReq) |
| 333 | resp, err := a.httpClient.Do(httpReq) |
| 334 | if err != nil { |
| 335 | return upstream.New(upstream.KindBackendUnhealthy, err.Error()) |
| 336 | } |
| 337 | defer resp.Body.Close() |
| 338 | if resp.StatusCode < 200 || resp.StatusCode >= 300 { |
| 339 | return upstream.New(upstream.KindBackendUnhealthy, fmt.Sprintf("health check failed status=%d path=%s", resp.StatusCode, path)) |
| 340 | } |
| 341 | return nil |
| 342 | } |
| 343 | |
| 344 | func (a *Adapter) isAzure() bool { |
| 345 | return a.cfg.Type == "azure_openai" |
nothing calls this directly
no test coverage detected