Documentation
¶
Overview ¶
Package server implements the HTTP server for the LLM Proxy. It handles request routing, lifecycle management, and provides health check endpoints and core API functionality.
Index ¶
Constants ¶
const Version = "0.1.0"
Version is the application version, following semantic versioning.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CachePurgeRequest ¶
type CachePurgeRequest struct {
Method string `json:"method" binding:"required"`
URL string `json:"url" binding:"required"`
Prefix string `json:"prefix,omitempty"`
}
CachePurgeRequest represents the request body for cache purge operations
type CachePurgeResponse ¶
type CachePurgeResponse struct {
Deleted interface{} `json:"deleted"` // bool for exact purge, int for prefix purge
}
CachePurgeResponse represents the response body for cache purge operations
type HealthResponse ¶
type HealthResponse struct {
Status string `json:"status"` // Service status, "ok" for a healthy system
Timestamp time.Time `json:"timestamp"` // Current server time
Version string `json:"version"` // Application version number
}
HealthResponse is the response body for the health check endpoint. It provides basic information about the server status and version.
type ProjectResponse ¶
type ProjectResponse struct {
ID string `json:"id"`
Name string `json:"name"`
APIKey string `json:"api_key"` // Obfuscated for security
IsActive bool `json:"is_active"`
DeactivatedAt *time.Time `json:"deactivated_at,omitempty"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
ProjectResponse is the sanitized project response with obfuscated API key
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server represents the HTTP server for the LLM Proxy. It encapsulates the underlying http.Server along with application configuration and handles request routing and server lifecycle management.
func New ¶
func New(cfg *config.Config, tokenStore token.TokenStore, projectStore proxy.ProjectStore) (*Server, error)
New creates a new HTTP server with the provided configuration and store implementations. It initializes the server with appropriate timeouts and registers all necessary route handlers. The server is not started until the Start method is called.
func NewWithDatabase ¶
func NewWithDatabase(cfg *config.Config, tokenStore token.TokenStore, projectStore proxy.ProjectStore, db *database.DB) (*Server, error)
NewWithDatabase creates a new HTTP server with database support for audit logging. This allows the server to store audit events in both file and database backends.
func (*Server) EventBus ¶
EventBus returns the event bus used by the server (may be nil if observability is disabled)
func (*Server) Shutdown ¶
Shutdown gracefully shuts down the server without interrupting active connections. It waits for all connections to complete or for the provided context to be canceled, whichever comes first.
The context should typically include a timeout to prevent the shutdown from blocking indefinitely.
type TokenListResponse ¶
type TokenListResponse struct {
ID string `json:"id"` // Token UUID (for API operations)
Token string `json:"token"` // Obfuscated token string (for display only)
ProjectID string `json:"project_id"`
ExpiresAt *time.Time `json:"expires_at"`
IsActive bool `json:"is_active"`
RequestCount int `json:"request_count"`
MaxRequests *int `json:"max_requests"`
CreatedAt time.Time `json:"created_at"`
LastUsedAt *time.Time `json:"last_used_at"`
CacheHitCount int `json:"cache_hit_count"`
}
TokenListResponse matches the sanitized token response schema (shared for tests and production)