You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Claw is a Middleware chaining module, compatible with
every mux who respects the http.Handler interface. Claw allows you
to create Stack of middleware for specific tasks.
Features
func (http.ResponseWriter, *http.Request) and func(http.Handler) http.Handler as Middleware.
Global Middleware.
Create Middleware Stack.
Claw runs middleware in order: last enter first to run
[ squiidz/claw/mw content a simple logger and gzip compressor middleware ]
Example
package main
import"github.com/go-zoo/claw"funcmain() {
// Create a new Claw instance, and set some Global Middleware.c:=claw.New(GlobalMiddleWare)
// You can also, create a Stack(), which is a stack// of MiddleWare for a specific taskauth:=c.NewStack(CheckUser, CheckToken, ValidSession)
// Wrap your global middleware with your handlerhttp.Handle("/home", c.Use(YourHandler))
// Add some middleware on a specific handler.http.Handle("/", c.Use(YourOtherHandler).Add(OtherMiddle))
// Add a Stack to the route.http.Handle("/", c.Use(YourOtherHandler).Stack(auth))
// Start Listening// You can also wrap the global middlewares directly on the router// instead of declaring claw.Use() on every handler,// use http.ListenAndServe(":8080", claw.Merge(mux))http.ListenAndServe(":8080", nil)
}
TODO
DOC
Refactoring
Debugging
Contributing
Fork it
Create your feature branch (git checkout -b my-new-feature)
Write Tests!
Commit your changes (git commit -am 'Add some feature')
Push to the branch (git push origin my-new-feature)