25 lines
462 B
Go
25 lines
462 B
Go
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}
|
|
}
|