Overview
Go-Mojito allows you to add middleware. Middlewares are exactly the same as regular handlers, except that they have an additional argument to call the next handler in chain, which is required.
This is a core part of the system, and works the same across all router implementations. This also means that this part cannot be swapped out easily.
Quick Start
-
Create a middleware func without any parameters
func myMiddleware() {}
-
Add
mojito.Context
,mojito.Logger
andfunc() error
arguments to the handler.func myMiddleware(ctx mojito.Context, logger mojito.Logger, next func() error) {}
-
Register the middleware on the router using the Go-Mojito shortcut. This will enable the middleware for all routes on the router.
func main() { mojito.WithMiddleware(myMiddleware) }
FAQ
No frequently asked questions yet!