https://github.com/rs/xaccess
Go http handler access logger
https://github.com/rs/xaccess
Last synced: about 1 year ago
JSON representation
Go http handler access logger
- Host: GitHub
- URL: https://github.com/rs/xaccess
- Owner: rs
- License: mit
- Created: 2015-10-26T22:52:07.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2016-08-03T17:08:26.000Z (almost 10 years ago)
- Last Synced: 2024-11-01T10:42:13.075Z (over 1 year ago)
- Language: Go
- Size: 6.84 KB
- Stars: 20
- Watchers: 3
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Go HTTP Handler Access Log
[](https://godoc.org/github.com/rs/xaccess) [](https://raw.githubusercontent.com/rs/xaccess/master/LICENSE) [](https://travis-ci.org/rs/xaccess) [](http://gocover.io/github.com/rs/xaccess)
Package xaccess is a middleware that logs all access requests performed on the sub handler using [xlog](https://github.com/rs/xlog) and [xstats](https://github.com/rs/xstats) stored in context if any.
## Usage
```go
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](https://raw.github.com/rs/xlog/master/LICENSE).