feat: Add TAG to logging from auth
This commit is contained in:
parent
631adc6b56
commit
71d36d63fe
5
auth.go
5
auth.go
@ -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)
|
||||||
|
Loading…
Reference in New Issue
Block a user