22 lines
322 B
Go
22 lines
322 B
Go
package kyra
|
|
|
|
import "log"
|
|
import "net/http"
|
|
|
|
type LoggerMiddle struct {
|
|
Logger *log.Logger
|
|
After http.Handler
|
|
}
|
|
|
|
func (l *LoggerMiddle) ServeHTTP(
|
|
w http.ResponseWriter, r *http.Request,
|
|
) {
|
|
if l.Logger != nil {
|
|
l.Logger.Printf(
|
|
"%s %s %q\n",
|
|
r.RemoteAddr, r.Method, r.URL,
|
|
)
|
|
}
|
|
l.After.ServeHTTP(w, r)
|
|
}
|
|
|