hooker/auth.go

25 lines
462 B
Go
Raw Normal View History

2023-09-19 22:47:19 +02:00
package main
import (
"log"
"net/http"
)
type AuthHandler struct {
Handler http.Handler
}
func (l *AuthHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
AuthHeader := r.Header.Get("Authorization")
if AuthHeader != task.Auth {
log.Printf("Dropping request from %s.", r.RemoteAddr)
return // drop
}
l.Handler.ServeHTTP(w, r)
}
func NewAuth(handler http.Handler) AuthHandler {
return AuthHandler{handler}
}