{"modulePath":"github.com/theopenlane/core/v2","version":"v2.18.2","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package server\n\nPackage server contains the server functions\n\n## Variables\n\n```go\nvar (\n\t// ErrFailedToGetFilePath is returned when runtime.Caller fails to get the current file path\n\tErrFailedToGetFilePath = errors.New(\"failed to get current file path\")\n\t// ErrSCIMSpecNotFound is returned when the SCIM spec file is not found\n\tErrSCIMSpecNotFound = errors.New(\"SCIM spec file not found\")\n\t// ErrMissingSpecInstances is returned when analyzed handlers reference model types absent from the generated instances file\n\tErrMissingSpecInstances = errors.New(\"model types missing from generated spec instances, run task generate:openapi to refresh them\")\n)\n```\n\n## Functions\n\n```go\nfunc ConfigureEcho(c LogConfig) *echo.Echo\n```\nConfigureEcho sets up the echo server with the default middleware and logging\n\n```go\nfunc CustomHTTPErrorHandler(c echo.Context, err error)\n```\nCustomHTTPErrorHandler is a custom error handler that logs the error and returns a JSON response\n\n```go\nfunc GenerateOpenAPISpecDocument() (*openapi3.T, error)\n```\nGenerateOpenAPISpecDocument builds a fully-registered OpenAPI document\n\n```go\nfunc GenerateOpenAPISpecFromRouter(router *route.Router) (*openapi3.T, error)\n```\nGenerateOpenAPISpecFromRouter builds the OpenAPI document from a router returned by RegisterSpecRoutes\n\n```go\nfunc NewOpenAPISpec() (*openapi3.T, error)\n```\nNewOpenAPISpec creates a new OpenAPI 3.1.0 specification based on the configured go interfaces and the operation types appended within the individual handlers\n\n```go\nfunc NewRouter(c LogConfig) *route.Router\n```\nNewRouter creates the runtime router; it carries no OpenAPI state, the published spec is generated ahead of time and served from the embedded artifact\n\n```go\nfunc NewSpecRouter(c LogConfig) (*route.Router, error)\n```\nNewSpecRouter creates a router in spec-build mode: route registration derives the OpenAPI document from the handler sources, reflecting schemas from the generated model instances. Only spec generation uses this\n\n```go\nfunc RegisterSpecRoutes() (*route.Router, error)\n```\nRegisterSpecRoutes builds a spec-mode router with all routes registered\n\n```go\nfunc SpecTypeNames(router *route.Router) []string\n```\nSpecTypeNames returns the sorted qualified names of every model type the analyzed handlers need, used by the instance emitter\n\n## Types\n\n```go\ntype LogConfig struct {\n\t// PrettyLog enables pretty logging output, defaults to json format\n\tPrettyLog bool\n\t// LogLevel sets the log level for the server, defaults to INFO\n\tLogLevel echo_log.Lvl\n\t// ClientIP configures how the request's real IP is resolved; it mirrors the rate limiter's settings so\n\t// request logs, audit records, and limiter keys agree\n\tClientIP clientip.Options\n}\n```\nLogConfig is a struct that holds the configuration for logging in the echo server\n\n```go\ntype SchemaRegistry struct {\n\t// contains filtered or unexported fields\n}\n```\nSchemaRegistry manages OpenAPI schemas dynamically\n\n```go\nfunc NewSchemaRegistry(spec *openapi3.T, opts ...openapi3gen.Option) *SchemaRegistry\n```\nNewSchemaRegistry creates a new schema registry\n\n```go\nfunc (r *SchemaRegistry) GetOrRegister(v any) (*openapi3.SchemaRef, error)\n```\nGetOrRegister gets an existing schema reference or reflects the value into the spec's component schemas and returns a reference to it\n\n```go\ntype Server struct {\n\n\t// Router makes the router directly accessible on the Server struct\n\tRouter *route.Router\n\t// contains filtered or unexported fields\n}\n```\nServer is a struct that holds the configuration for the server\n\n```go\nfunc NewServer(c config.Config) (*Server, error)\n```\nNewServer returns a new Server configuration\n\n```go\nfunc (s *Server) AddHandler(r handler)\n```\nAddHandler provides the ability to add additional HTTP handlers that process requests. The handler that is provided should have a Routes(\\*echo.Group) function, which allows the routes to be added to the server.\n\n```go\nfunc (s *Server) StartEchoServer(ctx context.Context) error\n```\nStartEchoServer creates and starts the echo server with configured middleware and handlers\n\n","path":"github.com/theopenlane/core/v2/internal/httpserve/server","name":"server","synopsis":"Package server contains the server functions","isRedistributable":true}
