package authz import "net/http" type Authorizer interface { Authorize(*http.Request) bool } type AuthorizerFunc func(*http.Request) bool func (f AuthorizerFunc) Authorize(r *http.Request) bool { return f(r) } func HTTP(authorizer Authorizer, h http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { if authorizer.Authorize(r) { h.ServeHTTP(w, r) } else { w.WriteHeader(http.StatusForbidden) } }) }