Middlewares
aah provides a way to create user-defined Middleware
for your application very similar to Go lang standard middleware.
Table of Contents
Writing Middleware
To create custom middleware, just comply to aah.MiddlewareFunc
. Once you created the middleware function.
Steps to add user-defined middleware(s) into aah
- Create a middleware in appropriate package
- Go to file
<app-base-dir>/app/init.go
- Look for
HTTPEngine().Middlewares(
- Add your middleware into the chain
Abort the Middleware Flow
You can abort the middleware flow in two ways.
Way One
Way Two
Bring Go lang native middleware into aah
aah expands the possibilities via reuse/existing middlewares.
- http.Handler
- http.HandlerFunc
func(http.ResponseWriter, *http.Request)