Documentation ¶
Overview ¶
Package middleware
this package re-export Chain from github.com/payfazz/httpchain
see subpackage for collections of middleware
Example ¶
if err := http.ListenAndServe(":8080", middleware.C( panicreporter.New(nil), reqlogger.New(nil), func(w http.ResponseWriter, r *http.Request) { switch r.URL.EscapedPath() { case "/hello": fmt.Fprintln(w, "hello world") return case "/random-panic": num := 10 / (rand.Int() % 2) fmt.Fprintf(w, "num = %d\n", num) return default: http.Error(w, "not found", 404) return } }, )); err != nil { panic(err) }
Output:
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Chain ¶
func Chain(all ...interface{}) http.HandlerFunc
Types ¶
This section is empty.
Directories ¶
Path | Synopsis |
---|---|
Package panicreporter provide middleware to report any golang panic.
|
Package panicreporter provide middleware to report any golang panic. |
Package reqlogger provide logger middleware for every http request.
|
Package reqlogger provide logger middleware for every http request. |
util
|
|
kv
Package kv provide key-value storage.
|
Package kv provide key-value storage. |
responsewriter
Package responsewriter.
|
Package responsewriter. |
Click to show internal directories.
Click to hide internal directories.