feat: Add TAG to logging from auth

This commit is contained in:
HeshamTB 2023-10-02 21:57:07 +03:00
parent 631adc6b56
commit 71d36d63fe

View File

@ -5,6 +5,9 @@ import (
"net/http" "net/http"
) )
// Java like
const TAG = "[ Auth ]"
type AuthHandler struct { type AuthHandler struct {
Handler http.Handler Handler http.Handler
} }
@ -14,7 +17,7 @@ func (l *AuthHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
AuthHeader := r.Header.Get("Authorization") AuthHeader := r.Header.Get("Authorization")
RealIP := r.Header.Get("X-Real-IP") RealIP := r.Header.Get("X-Real-IP")
if AuthHeader != task.Auth { if AuthHeader != task.Auth {
log.Printf("Dropping request from %s.", RealIP) log.Printf("%s Dropping request from %s", TAG, RealIP)
return // drop return // drop
} }
l.Handler.ServeHTTP(w, r) l.Handler.ServeHTTP(w, r)