Awesome
Go HTTP Handler Access Log
Package xaccess is a middleware that logs all access requests performed on the sub handler using xlog and xstats stored in context if any.
Usage
c := xhandler.Chain{}
c.UseC(xlog.NewHandler(xlog.Config{}))
c.UseC(xstats.NewHandler(dogstatsd.New(statsdWriter, flushInterval), tags))
c.UseC(xaccess.NewHandler())
http.Handle("/", c.Handler(xhandler.HandlerFuncC(func(ctx context.Context, w http.ResponseWriter, r *http.Request) {
w.Write([]byte("Hello World"))
})))
if err := http.ListenAndServe(":8080", nil); err != nil {
log.Fatal(err)
}
Licenses
All source code is licensed under the MIT License.