Documentation
¶
Index ¶
- Variables
- func AsPartofMiddlewareCollection(mw Middleware) any
- func AsPartofRouteCollection(route Route) any
- func BuildMiddlewareChain(finalHandler http.Handler, middlewares []Middleware) http.Handler
- func NewServer(lc fx.Lifecycle, logger slog.Logger, routeCollection []Route, ...) *http.Server
- type Middleware
- type Route
- type Router
- type ServeMuxRouter
- type ServerConfig
Constants ¶
This section is empty.
Variables ¶
View Source
var Module = fx.Module( "httpserver", fx.Provide( fx.Annotate( NewServerConfig, fx.ResultTags(`group:routes"`), fx.ResultTags("group:middleware"), ), ), )
Functions ¶
func AsPartofMiddlewareCollection ¶
func AsPartofMiddlewareCollection(mw Middleware) any
AsPartofMiddlewareCollection annotates a Middleware for inclusion in an Fx group.
func AsPartofRouteCollection ¶
AsPartofRouteCollection wraps a Route into an fx.Annotate to be included in a route collection.
func BuildMiddlewareChain ¶
func BuildMiddlewareChain(finalHandler http.Handler, middlewares []Middleware) http.Handler
BuildMiddlewareChain constructs a middleware chain from the provided middlewares and final handler. Middlewares are applied in the order they are provided, meaning the first middleware in the slice will be the outermost one to handle requests.
Types ¶
type Middleware ¶
Middleware is a function that wraps an http.Handler with additional functionality. It receives the next handler in the chain and returns a new handler. Middlewares can choose whether to call the next handler or stop the chain.
type Route ¶
type ServeMuxRouter ¶
type ServeMuxRouter struct {
// contains filtered or unexported fields
}
func (*ServeMuxRouter) Handler ¶
func (r *ServeMuxRouter) Handler() http.Handler
func (*ServeMuxRouter) RegisterRoute ¶
func (r *ServeMuxRouter) RegisterRoute(route Route)
type ServerConfig ¶
func NewServerConfig ¶
func NewServerConfig() *ServerConfig
func (*ServerConfig) Address ¶
func (c *ServerConfig) Address() string
Click to show internal directories.
Click to hide internal directories.