Documentation ¶
Index ¶
- Constants
- func CSRFProtect(config *support.Config) []func(next http.Handler) http.Handler
- func Recoverer(logger *support.Logger) func(next http.Handler) http.Handler
- func RequestLogger(config *support.Config, logger *support.Logger) func(next http.Handler) http.Handler
- type Context
- type Middlewares
- type Mux
- func (m *Mux) Group(fn func(r Router)) Router
- func (m *Mux) Handle(pattern string, handler http.Handler)
- func (m *Mux) HandleFunc(pattern string, handlerFn http.HandlerFunc)
- func (m *Mux) Match(ctx *Context, method, path string) bool
- func (m *Mux) Middlewares() Middlewares
- func (m *Mux) Mount(pattern string, handler http.Handler)
- func (m *Mux) Route(pattern string, fn func(r Router)) Router
- func (m *Mux) Routes() []Route
- func (m *Mux) Use(middlewares ...func(http.Handler) http.Handler)
- func (m *Mux) With(middlewares ...func(http.Handler) http.Handler) Router
- type Route
- type Router
- type SPAConfig
- type Server
Constants ¶
const ( // LiveReloadWSPort is the websocket port for the SSR live reload server. LiveReloadWSPort = "12450" // LiveReloadPath is the websocket path for the SSR live reload server. LiveReloadPath = "/reload" )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Context ¶
type Context = chi.Context
Context is the default routing context set on the root node of a request context to track route patterns, URL parameters and an optional routing path.
type Middlewares ¶
type Middlewares = chi.Middlewares
Middlewares type is a slice of standard middleware handlers with methods to compose middleware chains and http.Handler's.
type Mux ¶
type Mux struct {
*chi.Mux
}
Mux provides the routing logic.
func NewRouter ¶
func NewRouter() *Mux
NewRouter returns a new object that implements the Router interface.
func (*Mux) Group ¶
Group creates a new inline-Mux with a fresh middleware stack. It's useful for a group of handlers along the same routing path that use an additional set of middlewares.
func (*Mux) Handle ¶
Handle adds the route `pattern` that matches any http method to execute the `handler` http.Handler.
func (*Mux) HandleFunc ¶
func (m *Mux) HandleFunc(pattern string, handlerFn http.HandlerFunc)
HandleFunc adds the route `pattern` that matches any http method to execute the `handlerFn` http.HandlerFunc.
func (*Mux) Match ¶
Match searches the routing tree for a handler that matches the method/path. It's similar to routing a http request, but without executing the handler thereafter.
Note: the *Context state is updated during execution, so manage the state carefully.
func (*Mux) Middlewares ¶
func (m *Mux) Middlewares() Middlewares
Middlewares returns a slice of middleware handler functions.
func (*Mux) Mount ¶
Mount attaches another http.Handler or chi Router as a subrouter along a routing path. It's very useful to split up a large API as many independent routers and compose them as a single service using Mount.
Note that Mount() simply sets a wildcard along the `pattern` that will continue routing at the `handler`, which in most cases is another chi.Router. As a result, if you define two Mount() routes on the exact same pattern the mount will panic.
func (*Mux) Route ¶
Route creates a new Mux with a fresh middleware stack and mounts it along the `pattern` as a subrouter. Effectively, this is a short-hand call to Mount.
func (*Mux) Routes ¶
Routes returns a slice of routing information from the tree, useful for traversing available routes of a router.
func (*Mux) Use ¶
Use appends a middleware handler to the Mux middleware stack.
The middleware stack for any Mux will execute before searching for a matching route to a specific handler, which provides opportunity to respond early, change the course of the request execution, or set request-scoped values for the next http.Handler.
type SPAConfig ¶
SPAConfig defines the development web server URL for debug build and embed FS path for release build.
type Server ¶
type Server struct { SPAConfigs []SPAConfig *Mux *http.Server // contains filtered or unexported fields }
Server processes the HTTP requests.
func NewAppServer ¶
NewAppServer initializes the Server instance with built-in middleware.
func (*Server) SWFallbackDenyList ¶
SWFallbackDenyList generates the fallback deny list for service worker which is basically a list of GET routes that are defined on the server-side.