server

package
v0.9.5 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2026 License: MIT Imports: 35 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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
	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 returns a Conflict for a name already added.
	Add(name string, opts ...ServerOption) error
}

func New

func New(opts ...Option) Manager

type Option

type Option func(*manager)

func WithDebug added in v0.2.8

func WithDebug(enabled bool) Option

func WithLogger

func WithLogger(logger log.Logger) Option

type Route added in v0.9.2

type Route struct {
	Server     string
	Prefix     string // its group's
	Method     string
	Path       string // the prefix joined with the handler's own path
	Func       string
	Permission string
}

Route is one handler a router's config declares.

func CheckRouter added in v0.9.2

func CheckRouter(r api.Router) ([]Route, error)

CheckRouter parses r's config and resolves its handlers as RegisterRouters does, needing no server: a test calls it, so a router that would fail startup - a func its Handlers lack, a signature discovery skipped, a route declared twice - fails its tests instead. It returns what the config declares.

type Server

type Server interface {
	common.Named
	Endpoint() *api.Endpoint
}

type ServerOption

type ServerOption func(*server)

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 enables HTTP metrics; the meter is not a dependency, so a collector outage never takes down the listener.

func WithMiddlewareConfigs added in v0.6.1

func WithMiddlewareConfigs(defaults []byte) ServerOption

WithMiddlewareConfigs maps name to a switch (boolean) or config block; a WithMiddlewares entry without a key stays dormant.

func WithMiddlewares added in v0.6.0

func WithMiddlewares(mws ...api.Middleware) ServerOption

WithMiddlewares runs on every request, matched or not (e.g. cors), before RequestInfo exists.

func WithTLS

func WithTLS(cert certutil.CertBundle, clientCAs ...*x509.Certificate) ServerOption

WithTLS serves https with cert, verifying a client certificate, when one is given, against clientCAs; none is asked for without them.

Jump to

Keyboard shortcuts

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