router

package
v0.0.16 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2021 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Service = dependency.Service{
	Dependencies: fx.Provide(
		func(router *mux.Router) http.Handler {
			return router
		},
	),
	Constructor: New,
}

Service is how the dependency is provided to the dependency builder

Functions

func New

func New(params Params) *mux.Router

New creates a new instance of a *mux.Router with all of the modules added

func New404Handler

func New404Handler(provider response.ResponderProvider) http.Handler

New404Handler produces an http.Handler that is used as the default 404 handler

func New405Handler

func New405Handler(provider response.ResponderProvider) http.Handler

New405Handler produces an http.Handler that is used as the default 405 handler

Types

type ApplierFunc

type ApplierFunc func(router *mux.Router)

ApplierFunc is a function type that allows routes to be applied to the main router

type Module

type Module struct {
	Path   string
	Router ApplierFunc
}

Module is a group of routes to route to based on a path

func (Module) PathPrefix

func (m Module) PathPrefix() string

PathPrefix returns the path with a slash at the start

type Params

type Params struct {
	fx.In

	ResponseProvider response.ResponderProvider
	Modules          []Module             `group:"server"`
	Middlewares      []mux.MiddlewareFunc `group:"middleware"`
}

Params are the parameters required to build the router

Jump to

Keyboard shortcuts

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