http

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ModuleName string = "http-server"
)

Variables

View Source
var (
	ErrUnknownMethod error = fmt.Errorf("unknown http method")
	ErrUnknownModule       = fmt.Errorf("module is not the %s module", ModuleName)
)

Functions

func WithPolicy added in v0.5.0

func WithPolicy(name string, mw ...gin.HandlerFunc) modules.Option

WithPolicy registers a named bundle of middleware, executed in the given order by every group or route that applies it with Policy(name). A route exporter may also map the policy name to proxy middleware, the request then passes through those on the proxy first, before reaching the service.

func WithRequestLogger deprecated

func WithRequestLogger() modules.Option

Deprecated: this option has no effect, the module is always logging and setting the request logger, regardless if this options is used or not and will be removed in future.

func WithRoute deprecated

func WithRoute(route Route) modules.Option

Deprecated: use DefineRoutes.

func WithRouteExporter added in v0.5.0

func WithRouteExporter(exporter route.Exporter) modules.Option

WithRouteExporter adds an exporter that receives every route defined so far after each successful DefineRoutes call, e.g. to write proxy configuration. Can be used more than once.

func WithServerPort

func WithServerPort(port int) modules.Option

Types

type Module

type Module struct {
	modules.Base
	// contains filtered or unexported fields
}

func New

func New() *Module

func (*Module) Configure

func (m *Module) Configure(opts ...modules.Option) error

func (*Module) DefineRoutes added in v0.5.0

func (m *Module) DefineRoutes(prefix string, fn func(*route.Group)) error

DefineRoutes defines routes under prefix through fn, validates them against all previously defined routes, registers them with the router and runs the route exporters. Call it after Configure so the module's global middleware applies to the defined routes. A validation error registers nothing, but an error from the router or an exporter can leave routes of this call served.

func (*Module) RegisterRoute deprecated

func (m *Module) RegisterRoute(route Route) error

Deprecated: use DefineRoutes.

func (*Module) RegisterRoutes deprecated

func (m *Module) RegisterRoutes(routes ...Route) error

Deprecated: use DefineRoutes.

func (*Module) Router

func (m *Module) Router() *gin.Engine

func (*Module) Shutdown

func (m *Module) Shutdown() error

func (*Module) Start

func (m *Module) Start() error

type Route deprecated

type Route struct {
	Group      string
	Handler    gin.HandlerFunc
	URI        string
	HTTPMethod string
}

Deprecated: use DefineRoutes.

Directories

Path Synopsis
tests

Jump to

Keyboard shortcuts

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