Home

Awesome

claw GoDoc Build Status

What is claw ?

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.

alt tag

Features

[ squiidz/claw/mw content a simple logger and gzip compressor middleware ]

Example

package main

import "github.com/go-zoo/claw"

func main() {
	// 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 task
	auth := c.NewStack(CheckUser, CheckToken, ValidSession)

	// Wrap your global middleware with your handler
	http.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

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Write Tests!
  4. Commit your changes (git commit -am 'Add some feature')
  5. Push to the branch (git push origin my-new-feature)
  6. Create new Pull Request

License

MIT

Links

Lightning Fast HTTP Mux : Bone