server

package
v0.0.0-...-ce1014b Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2026 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewIPAccessControlRuntime

func NewIPAccessControlRuntime(cfg Config) (*middleware.IPAccessControlConfig, error)

NewIPAccessControlRuntime creates the single mutable runtime state used by the IP access-control middleware. SIGHUP reload handling updates this object directly instead of rebuilding routes or introducing a global configuration event bus.

func Run

func Run(opts ...fx.Option)

func SetupRoutes

func SetupRoutes(server *Server, handlers Handlers, client *ent.Client, services Services, ipAccessControl *middleware.IPAccessControlConfig)

Types

type API

type API struct {
	Auth APIAuth `conf:"auth" yaml:"auth" json:"auth"`
}

type APIAuth

type APIAuth struct {
	AllowNoAuth bool   `conf:"allow_no_auth" yaml:"allow_no_auth" json:"allow_no_auth"`
	KeyPrefix   string `conf:"key_prefix" yaml:"key_prefix" json:"key_prefix"`
}

type CORS

type CORS struct {
	Enabled          bool          `conf:"enabled" yaml:"enabled" json:"enabled"`
	AllowedOrigins   []string      `conf:"allowed_origins" yaml:"allowed_origins" json:"allowed_origins"`
	AllowedMethods   []string      `conf:"allowed_methods" yaml:"allowed_methods" json:"allowed_methods"`
	AllowedHeaders   []string      `conf:"allowed_headers" yaml:"allowed_headers" json:"allowed_headers"`
	ExposedHeaders   []string      `conf:"exposed_headers" yaml:"exposed_headers" json:"exposed_headers"`
	AllowCredentials bool          `conf:"allow_credentials" yaml:"allow_credentials" json:"allow_credentials"`
	MaxAge           time.Duration `conf:"max_age" yaml:"max_age" json:"max_age"`
}

type Config

type Config struct {
	Host        string        `conf:"host" yaml:"host" json:"host"`
	Port        int           `conf:"port" yaml:"port" json:"port"`
	PublicURL   string        `conf:"public_url" yaml:"public_url" json:"public_url"`
	Name        string        `conf:"name" yaml:"name" json:"name"`
	BasePath    string        `conf:"base_path" yaml:"base_path" json:"base_path"`
	PidFile     string        `conf:"pid_file" yaml:"pid_file" json:"pid_file"`
	ReadTimeout time.Duration `conf:"read_timeout" yaml:"read_timeout" json:"read_timeout"`

	// RequestTimeout is the maximum duration for processing a request.
	RequestTimeout time.Duration `conf:"request_timeout" yaml:"request_timeout" json:"request_timeout"`

	// LLMRequestTimeout is the maximum duration for processing a request to LLM.
	LLMRequestTimeout time.Duration `conf:"llm_request_timeout" yaml:"llm_request_timeout" json:"llm_request_timeout"`

	Trace     tracing.Config `conf:"trace" yaml:"trace" json:"trace"`
	Dashboard Dashboard      `conf:"dashboard" yaml:"dashboard" json:"dashboard"`

	Debug            bool            `conf:"debug" yaml:"debug" json:"debug"`
	DisableSSLVerify bool            `conf:"disable_ssl_verify" yaml:"disable_ssl_verify" json:"disable_ssl_verify"`
	CORS             CORS            `conf:"cors" yaml:"cors" json:"cors"`
	API              API             `conf:"api" yaml:"api" json:"api"`
	IPAccessControl  IPAccessControl `conf:"ip_access_control" yaml:"ip_access_control" json:"ip_access_control"`
}

type Dashboard

type Dashboard struct {
	// AllTimeTokenStatsSoftTTL is the duration after which cached all-time token stats
	// are considered stale and will be refreshed asynchronously (stale-while-revalidate).
	// Default: 1 hour
	AllTimeTokenStatsSoftTTL time.Duration `conf:"all_time_token_stats_soft_ttl" yaml:"all_time_token_stats_soft_ttl" json:"all_time_token_stats_soft_ttl"`

	// AllTimeTokenStatsHardTTL is the maximum duration for which cached all-time token stats
	// are considered valid. After this, synchronous refresh is required.
	// Default: 24 hours
	AllTimeTokenStatsHardTTL time.Duration `conf:"all_time_token_stats_hard_ttl" yaml:"all_time_token_stats_hard_ttl" json:"all_time_token_stats_hard_ttl"`
}

Dashboard holds configuration for the dashboard cache settings.

type Handlers

type Handlers struct {
	fx.In

	Graphql        *gql.GraphqlHandler
	OpenAPIGraphql *openapi.GraphqlHandler
	OpenAI         *api.OpenAIHandlers
	Adapter        *api.AdapterHandlers
	Doubao         *api.DoubaoHandlers
	Anthropic      *api.AnthropicHandlers
	Gemini         *api.GeminiHandlers
	AiSDK          *api.AiSDKHandlers
	Playground     *api.PlaygroundHandlers
	System         *api.SystemHandlers
	Auth           *api.AuthHandlers
	Jina           *api.JinaHandlers
	Codex          *api.CodexHandlers
	ClaudeCode     *api.ClaudeCodeHandlers
	Antigravity    *api.AntigravityHandlers
	Copilot        *api.CopilotHandlers
	RequestContent *api.RequestContentHandlers
	OIDC           *api.OIDCHandlers
	RequestPreview *api.RequestPreviewHandlers
	Gateway        *api.GatewayHandlers
}

type IPAccessControl

type IPAccessControl struct {
	Enabled     bool     `conf:"enabled" yaml:"enabled" json:"enabled"`
	AllowedIPs  []string `conf:"allowed_ips" yaml:"allowed_ips" json:"allowed_ips"`
	RedirectURL string   `conf:"redirect_url" yaml:"redirect_url" json:"redirect_url"`
}

type Server

type Server struct {
	*gin.Engine

	Config Config
	// contains filtered or unexported fields
}

func New

func New(config Config) *Server

func (*Server) Run

func (srv *Server) Run() error

func (*Server) Shutdown

func (srv *Server) Shutdown(ctx context.Context) error

type Services

type Services struct {
	fx.In

	TraceService   *biz.TraceService
	ThreadService  *biz.ThreadService
	AuthService    *biz.AuthService
	SystemService  *biz.SystemService
	AdapterService *biz.AdapterService
}

Directories

Path Synopsis
biz
racetest
Package racetest holds opt-in, build-tagged integration tests that need a real concurrent database (PostgreSQL, MySQL, or TiDB).
Package racetest holds opt-in, build-tagged integration tests that need a real concurrent database (PostgreSQL, MySQL, or TiDB).
gql
qb
Package qb provides database utilities and query builders for llm-proxy.
Package qb provides database utilities and query builders for llm-proxy.

Jump to

Keyboard shortcuts

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