Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Manager ¶
type Manager interface {
common.Service
// health.go: a listener that stopped serving fails both probes - a
// restart rebuilds the echo instances and re-binds it, so it is
// liveness-fixable, and it is equally not ready for traffic.
common.Liveness
common.Readiness
common.Initializable
common.Daemon
Get(name string) (Server, error)
List() []Server
RegisterRouters(routers ...api.Router) error
RegisterMiddlewares(middlewares ...api.Middleware) error
// Add creates the named server instance; a name already added is a
// Conflict rather than a silent replacement.
Add(name string, opts ...ServerOption) error
}
Manager manages multiple server instances.
type ServerOption ¶
type ServerOption func(*server)
ServerOption configures a server (echo server instance)
func WithEndpoint ¶
func WithEndpoint(host string, port uint, prefix string) ServerOption
func WithMeter ¶ added in v0.6.15
func WithMeter(meter model.Meter) ServerOption
WithMeter turns on the server's HTTP metrics - request duration, active requests and body sizes, recorded through the given handle for every request this server instance serves, matched or not. A server without one records into noop instruments and nothing lands - the case for an app that wires no metrics service; with one, the metrics service's own enabled switch decides what exports. The meter is deliberately not a dependency of the api server: the metrics service has liveness only, and a collector outage or an unconfigured exporter must degrade metrics, never the listener.
func WithMiddlewareConfigs ¶ added in v0.6.1
func WithMiddlewareConfigs(defaults []byte) ServerOption
WithMiddlewareConfigs sets the server's default middleware configs, a plain mapping of middleware name to value - unlike a router.yaml middleware list, which stays a sequence because attachment order matters there:
cors: true throttle: rps: 100.0 burst_size: 200
A boolean value is a switch, not config: cors: false disables the cors middleware wherever nothing more specific overrides it, and cors: true enables it with no config. A block is config and resolves most-specific-first into Func's config argument: a handler entry's own block, else its group entry's, else this mapping's, else nil.
For server-level middlewares (WithMiddlewares) this mapping is also the activation: no entry leaves one dormant, a null or true entry enables it, a block enables and configures, false switches it off. The lifecycle built-ins (metrics, recover, logger, info, error) take no config and claim no names - every name here belongs to the app's middlewares. Invalid YAML fails Add.
func WithMiddlewares ¶ added in v0.6.0
func WithMiddlewares(mws ...api.Middleware) ServerOption
WithMiddlewares installs middlewares on the server itself, running on every request - matched or not - inside the built-in recover but ahead of the rest of the lifecycle, in the order given. This is the position router.yaml cannot express, which is where an app's cors middleware belongs: preflight requests match no route. Each is built with the server's middleware config under its name and survives the echo rebuild a restart performs. RequestInfo does not exist yet at this position; a middleware that reads it belongs in router.yaml instead.
func WithTLS ¶
func WithTLS(cert certutil.CertBundle, auth bool) ServerOption