Documentation
¶
Overview ¶
Package server contains the server functions
Index ¶
- Variables
- func ConfigureEcho(c LogConfig) *echo.Echo
- func CustomHTTPErrorHandler(c echo.Context, err error)
- func GenerateOpenAPISpecDocument() (*openapi3.T, error)
- func GenerateOpenAPISpecFromRouter(router *route.Router) (*openapi3.T, error)
- func NewOpenAPISpec() (*openapi3.T, error)
- func NewRouter(c LogConfig) *route.Router
- func NewSpecRouter(c LogConfig) (*route.Router, error)
- func RegisterSpecRoutes() (*route.Router, error)
- func SpecTypeNames(router *route.Router) []string
- type LogConfig
- type SchemaRegistry
- type Server
Constants ¶
This section is empty.
Variables ¶
var ( // ErrFailedToGetFilePath is returned when runtime.Caller fails to get the current file path ErrFailedToGetFilePath = errors.New("failed to get current file path") // ErrSCIMSpecNotFound is returned when the SCIM spec file is not found ErrSCIMSpecNotFound = errors.New("SCIM spec file not found") // ErrMissingSpecInstances is returned when analyzed handlers reference model types absent from the generated instances file ErrMissingSpecInstances = errors.New("model types missing from generated spec instances, run task generate:openapi to refresh them") )
Functions ¶
func ConfigureEcho ¶
ConfigureEcho sets up the echo server with the default middleware and logging
func CustomHTTPErrorHandler ¶
CustomHTTPErrorHandler is a custom error handler that logs the error and returns a JSON response
func GenerateOpenAPISpecDocument ¶
GenerateOpenAPISpecDocument builds a fully-registered OpenAPI document
func GenerateOpenAPISpecFromRouter ¶
GenerateOpenAPISpecFromRouter builds the OpenAPI document from a router returned by RegisterSpecRoutes
func NewOpenAPISpec ¶
NewOpenAPISpec creates a new OpenAPI 3.1.0 specification based on the configured go interfaces and the operation types appended within the individual handlers
func NewRouter ¶
NewRouter creates the runtime router; it carries no OpenAPI state, the published spec is generated ahead of time and served from the embedded artifact
func NewSpecRouter ¶
NewSpecRouter 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
func RegisterSpecRoutes ¶
RegisterSpecRoutes builds a spec-mode router with all routes registered
func SpecTypeNames ¶
SpecTypeNames returns the sorted qualified names of every model type the analyzed handlers need, used by the instance emitter
Types ¶
type LogConfig ¶
type LogConfig struct {
// PrettyLog enables pretty logging output, defaults to json format
PrettyLog bool
// LogLevel sets the log level for the server, defaults to INFO
LogLevel echo_log.Lvl
}
LogConfig is a struct that holds the configuration for logging in the echo server
type SchemaRegistry ¶
type SchemaRegistry struct {
// contains filtered or unexported fields
}
SchemaRegistry manages OpenAPI schemas dynamically
func NewSchemaRegistry ¶
func NewSchemaRegistry(spec *openapi3.T, opts ...openapi3gen.Option) *SchemaRegistry
NewSchemaRegistry creates a new schema registry
func (*SchemaRegistry) GetOrRegister ¶
func (r *SchemaRegistry) GetOrRegister(v any) (*openapi3.SchemaRef, error)
GetOrRegister gets an existing schema reference or reflects the value into the spec's component schemas and returns a reference to it
type Server ¶
type Server struct {
// Router makes the router directly accessible on the Server struct
Router *route.Router
// contains filtered or unexported fields
}
Server is a struct that holds the configuration for the server
func (*Server) AddHandler ¶
func (s *Server) AddHandler(r handler)
AddHandler 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.