Documentation
¶
Overview ¶
Package server contains the server functions
Index ¶
- Variables
- func CollectSpecTypes() ([]string, error)
- func ConfigureEcho(c LogConfig) *echo.Echo
- func CustomHTTPErrorHandler(c echo.Context, err error)
- func GenerateOpenAPISpecDocument() (*openapi3.T, error)
- func NewOpenAPISpec() (*openapi3.T, error)
- func NewRouter(c LogConfig) *route.Router
- func NewSpecRouter(c LogConfig) (*route.Router, error)
- 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 CollectSpecTypes ¶ added in v1.28.0
CollectSpecTypes registers all routes in spec-build mode and returns the sorted qualified names of every model type the analyzed handlers need; used by the instance emitter
func ConfigureEcho ¶ added in v0.8.6
ConfigureEcho sets up the echo server with the default middleware and logging
func CustomHTTPErrorHandler ¶ added in v0.8.6
CustomHTTPErrorHandler is a custom error handler that logs the error and returns a JSON response
func GenerateOpenAPISpecDocument ¶ added in v0.45.8
GenerateOpenAPISpecDocument builds a fully-registered OpenAPI document
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 ¶ added in v1.28.0
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
Types ¶
type LogConfig ¶ added in v0.18.9
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 ¶ added in v0.25.0
type SchemaRegistry struct {
// contains filtered or unexported fields
}
SchemaRegistry manages OpenAPI schemas dynamically
func NewSchemaRegistry ¶ added in v0.25.0
func NewSchemaRegistry(spec *openapi3.T, opts ...openapi3gen.Option) *SchemaRegistry
NewSchemaRegistry creates a new schema registry
func (*SchemaRegistry) GetOrRegister ¶ added in v0.25.0
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.