gocustomurls/middleware.go

24 lines
575 B
Go

package main
import (
"net/http"
)
// serveLogger is a logging middleware for serving. It generates logs for
// requests sent to the server.
func serveLogger(l *LogFile) func(http.HandlerFunc) http.HandlerFunc {
return func(next http.HandlerFunc) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
l.WriteLog(r)
next(w, r)
}
}
}
// func serveLogger(logger *LogFile, next http.Handler) http.Handler {
// return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
// logger.WriteLog(r)
// next.ServeHTTP(w, r)
// })
// }