Documentation
¶
Overview ¶
Package server wires the HTTP layer: routes, auth, upstream proxying with streaming, and request logging. The panel API lives in package api.
Index ¶
- func APIKeyFromContext(ctx context.Context) *store.APIKey
- func InvalidateKeyCache()
- type Server
- func (s *Server) CountTokens() http.HandlerFunc
- func (s *Server) Handler(panelAssets http.FileSystem, panelMux http.Handler) http.Handler
- func (s *Server) OpenAIProxy() http.HandlerFunc
- func (s *Server) Proxy() http.HandlerFunc
- func (s *Server) ResponsesProxy() http.HandlerFunc
- func (s *Server) Shutdown() error
- func (s *Server) Start(handler http.Handler) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func APIKeyFromContext ¶ added in v1.1.0
APIKeyFromContext returns the authenticated API key placed by clientAuth, or nil if the request was allowed through without a key (RequireAPIKey=false).
func InvalidateKeyCache ¶ added in v1.1.0
func InvalidateKeyCache()
InvalidateKeyCache drops all cached entries (call after create/update/delete).
Types ¶
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server is the top-level HTTP server. It owns the config, store, and the underlying *http.Server so it can be shut down cleanly.
func (*Server) CountTokens ¶
func (s *Server) CountTokens() http.HandlerFunc
CountTokens handles POST /v1/messages/count_tokens with a rough estimate (~4 chars/token), which is all Claude Code uses it for.
func (*Server) Handler ¶
Handler returns the root http.Handler wiring all routes. panelAssets serves the embedded SPA (nil = no embedded assets, e.g. dev mode).
func (*Server) OpenAIProxy ¶ added in v1.1.1
func (s *Server) OpenAIProxy() http.HandlerFunc
OpenAIProxy handles POST /v1/chat/completions. Unlike Proxy, this endpoint accepts and returns OpenAI wire format, so OpenAI-compatible SDKs can point their base URL at opencode-cc directly.
func (*Server) Proxy ¶
func (s *Server) Proxy() http.HandlerFunc
Proxy handles POST /v1/messages. Native Anthropic-capable target models go straight to the upstream Messages API; all other models are translated to OpenAI Chat Completions and converted back.
func (*Server) ResponsesProxy ¶ added in v1.2.0
func (s *Server) ResponsesProxy() http.HandlerFunc
ResponsesProxy handles POST /v1/responses for Codex and other Responses API clients. Anthropic-native target models are translated through the upstream Messages API; other models use OpenAI Chat Completions translation.