Documentation
¶
Index ¶
- func Module() fx.Option
- func RegisterRouteMappings(router Router, routes RouteMappings, logger xlog.OptionalLogger)
- func RegisterSafeHandlers(router Router, notFound NotFound, methodNotAllowed MethodNotAllowed, ...)
- func Start(_ context.Context, server HTTPServer, logger xlog.OptionalLogger) error
- func Stop(ctx context.Context, server HTTPServer, logger xlog.OptionalLogger) error
- func WithMiddleware(middleware ...Middleware) func(*Route)
- func WithPriority(priority int) func(*Route)
- type CompressQualifier
- type Config
- type ConfigTimeouts
- type HTTPServer
- type HTTPServerQualifier
- type LoadConfigParams
- type MethodNotAllowed
- type MethodNotAllowedRouteMapping
- type Middleware
- type NotFound
- type NotFoundRouteMapping
- type Route
- type RouteMapping
- func DELETE(path string, handler http.Handler, options ...func(*Route)) RouteMapping
- func GET(path string, handler http.Handler, options ...func(*Route)) RouteMapping
- func Handle(method, path string, handler http.Handler, options ...func(*Route)) RouteMapping
- func OPTIONS(path string, handler http.Handler, options ...func(*Route)) RouteMapping
- func PATCH(path string, handler http.Handler, options ...func(*Route)) RouteMapping
- func POST(path string, handler http.Handler, options ...func(*Route)) RouteMapping
- func PUT(path string, handler http.Handler, options ...func(*Route)) RouteMapping
- type RouteMappings
- type Router
- type RouterQualifier
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RegisterRouteMappings ¶
func RegisterRouteMappings(router Router, routes RouteMappings, logger xlog.OptionalLogger)
RegisterRouteMappings register the given routes.
func RegisterSafeHandlers ¶
func RegisterSafeHandlers(router Router, notFound NotFound, methodNotAllowed MethodNotAllowed, logger xlog.OptionalLogger)
func Start ¶
func Start(_ context.Context, server HTTPServer, logger xlog.OptionalLogger) error
Start starts the Server.
func Stop ¶
func Stop(ctx context.Context, server HTTPServer, logger xlog.OptionalLogger) error
Stop stop the Server
func WithMiddleware ¶
func WithMiddleware(middleware ...Middleware) func(*Route)
noinspection GoUnusedExportedFunction
func WithPriority ¶
noinspection GoUnusedExportedFunction
Types ¶
type CompressQualifier ¶
type CompressQualifier struct { fx.Out Middleware Middleware `name:"x_compress_middleware"` }
func NewCompressMiddleware ¶
func NewCompressMiddleware() CompressQualifier
type Config ¶
type Config struct { Addr string `yaml:"addr"` Timeouts ConfigTimeouts `yaml:"timeouts"` }
Config holds server configuration
func LoadConfig ¶
func LoadConfig(params LoadConfigParams) (Config, error)
type ConfigTimeouts ¶
type HTTPServer ¶
HTTPServer ir necessary to access the server by name
type HTTPServerQualifier ¶
HTTPServerQualifier is necessary to give a name to the server
func NewHTTPServer ¶
func NewHTTPServer(cfg Config, router Router) HTTPServerQualifier
NewHTTPServer returns a *http.Server with timeouts configured by Config.
type LoadConfigParams ¶
type MethodNotAllowed ¶
type NotFoundRouteMapping ¶
type Route ¶
type Route struct { // Priority The bigger, the sooner the route will be registered. // Important: The order of Routes with the same priority is not guarantee. Priority int // Method HTTP Method which the route must accept Method string // Path is the URL path // e.g: /hello/{name} Path string // Middleware a list of middleware that must be applied, // Important: Middleware are applied in the given order. Middleware []Middleware // Handler the standard go HTTP handler Handler http.Handler }
Route holds everything the router needs to know to register a route into the container
type RouteMapping ¶
RouteMapping Necessary to register more than one Route
func Handle ¶
func Handle(method, path string, handler http.Handler, options ...func(*Route)) RouteMapping
type RouteMappings ¶
RouteMappings group routes to be registered by the Server. It is populated by the container with all routes from the group `routes`
type RouterQualifier ¶
func NewEmptyRouter ¶
func NewEmptyRouter() RouterQualifier
NewEmptyRouter creates a new HTTP server Mux and register the given routes.