server

package
v2.3.0 Latest Latest
Warning

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

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

Documentation

Overview

Package server contains the server functions

Index

Constants

This section is empty.

Variables

View Source
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

func CollectSpecTypes() ([]string, error)

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

func ConfigureEcho(c LogConfig) *echo.Echo

ConfigureEcho sets up the echo server with the default middleware and logging

func CustomHTTPErrorHandler

func CustomHTTPErrorHandler(c echo.Context, err error)

CustomHTTPErrorHandler is a custom error handler that logs the error and returns a JSON response

func GenerateOpenAPISpecDocument

func GenerateOpenAPISpecDocument() (*openapi3.T, error)

GenerateOpenAPISpecDocument builds a fully-registered OpenAPI document

func NewOpenAPISpec

func NewOpenAPISpec() (*openapi3.T, error)

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

func NewRouter(c LogConfig) *route.Router

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

func NewSpecRouter(c LogConfig) (*route.Router, error)

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

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 NewServer

func NewServer(c config.Config) (*Server, error)

NewServer returns a new Server configuration

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.

func (*Server) StartEchoServer

func (s *Server) StartEchoServer(ctx context.Context) error

StartEchoServer creates and starts the echo server with configured middleware and handlers

Jump to

Keyboard shortcuts

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