https://github.com/vanng822/accesslog
Access logging middleware
https://github.com/vanng822/accesslog
Last synced: about 2 months ago
JSON representation
Access logging middleware
- Host: GitHub
- URL: https://github.com/vanng822/accesslog
- Owner: vanng822
- License: mit
- Created: 2015-04-06T15:05:02.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2015-05-05T07:24:05.000Z (almost 10 years ago)
- Last Synced: 2025-01-18T05:27:31.883Z (3 months ago)
- Language: Go
- Size: 176 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## Accesslog
Accesslog is a middleware for logging access with interfaces func(next http.Handler) http.Handler and HandlerFuncWithNext(w http.ResponseWriter, r *http.Request, next http.HandlerFunc). See http://en.wikipedia.org/wiki/Common_Log_Format for log format.
## Example
```go
package mainimport (
"fmt"
"github.com/vanng822/accesslog"
"github.com/vanng822/r2router"
"net/http"
"log"
)func main() {
seefor := r2router.NewSeeforRouter()
l := accesslog.New()
seefor.Before(l.Handler)
seefor.Get("/hello/:name", func(w http.ResponseWriter, r *http.Request, p r2router.Params) {
fmt.Fprintf(w, "Hello %s!", p.Get("name"))
})
log.Fatal(http.ListenAndServe(":8080", seefor))
}
```