Documentation
¶
Index ¶
- Constants
- Variables
- func WithPolicy(name string, mw ...gin.HandlerFunc) modules.Option
- func WithRequestLogger() modules.Optiondeprecated
- func WithRoute(route Route) modules.Optiondeprecated
- func WithRouteExporter(exporter route.Exporter) modules.Option
- func WithServerPort(port int) modules.Option
- type Module
- func (m *Module) Configure(opts ...modules.Option) error
- func (m *Module) DefineRoutes(prefix string, fn func(*route.Group)) error
- func (m *Module) RegisterRoute(route Route) errordeprecated
- func (m *Module) RegisterRoutes(routes ...Route) errordeprecated
- func (m *Module) Router() *gin.Engine
- func (m *Module) Shutdown() error
- func (m *Module) Start() error
- type Routedeprecated
Constants ¶
const (
ModuleName string = "http-server"
)
Variables ¶
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 WithRouteExporter ¶ added in v0.5.0
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 ¶
Types ¶
type Module ¶
func (*Module) DefineRoutes ¶ added in v0.5.0
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.