handler

package
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 27, 2026 License: BSD-2-Clause Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultProxyTransport added in v0.3.0

func DefaultProxyTransport() *http.Transport

DefaultProxyTransport returns an http.Transport with explicit timeouts suitable for upstream LLM API calls. Long ResponseHeaderTimeout because LLM completions can take 30s+ for the first byte (SSE); short Dial because connections are local-network or quick HTTPS to api.anthropic.com.

func NewAnthropicProxyHandler added in v0.3.0

func NewAnthropicProxyHandler(upstream *url.URL, transport http.RoundTripper) http.Handler

NewAnthropicProxyHandler returns an HTTP handler that reverse-proxies every incoming request to upstream (typically https://api.anthropic.com).

The Authorization header passes through unchanged — this is what lets Claude Code's subscription OAuth bearer travel through the router to Anthropic without the router ever holding it. No body parsing, no model-based routing: that's task 3. v1 of task 2 = single upstream, verbatim forward.

Upstream errors (connection refused, 5xx before body, etc.) are logged server-side with the full error string for debugging, but the client sees only a generic "502 Bad Gateway / upstream unavailable" — the internal error details (IPs, TLS handshake failures, connection strings) are not leaked.

If transport is nil, DefaultProxyTransport is used.

func NewHealthzHandler

func NewHealthzHandler() http.Handler

NewHealthzHandler returns a handler that responds 200 with body "OK".

func NewLoggingHandler added in v0.2.0

func NewLoggingHandler(next http.Handler) http.Handler

NewLoggingHandler wraps next and emits one glog line per request: `[req] METHOD path -> STATUS` at V(1). Used to make router activity visible during local testing without depending on the upstream provider's own logging.

func NewSetLoglevelHandler

func NewSetLoglevelHandler() http.Handler

NewSetLoglevelHandler returns a no-op handler for /setloglevel/{level}.

v1 skeleton: slog level is static; nothing to switch at runtime. The endpoint exists so the canonical-admin-endpoints check passes and so future runtime log-level wiring has a known URL. Returns 200 with body "noop" so callers can distinguish from "endpoint missing".

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL