2024-08-02 18:30:32 +03:00
|
|
|
package kyra
|
2024-06-09 16:26:31 +03:00
|
|
|
|
|
|
|
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)
|
|
|
|
}
|
|
|
|
|