mirror of
https://github.com/safing/portbase
synced 2026-05-04 22:52:05 +00:00
Implement review suggestions
This commit is contained in:
parent
5daeac8cf7
commit
3244fefd43
10 changed files with 118 additions and 111 deletions
|
|
@ -3,24 +3,20 @@ package api
|
|||
import "net/http"
|
||||
|
||||
// WrapInAuthHandler wraps a simple http.HandlerFunc into a handler that
|
||||
// exposes the given API permissions.
|
||||
// exposes the required API permissions for this handler.
|
||||
func WrapInAuthHandler(fn http.HandlerFunc, read, write Permission) http.Handler {
|
||||
return &wrappedAuthenticatedHandler{
|
||||
handleFunc: fn,
|
||||
read: read,
|
||||
write: write,
|
||||
HandlerFunc: fn,
|
||||
read: read,
|
||||
write: write,
|
||||
}
|
||||
}
|
||||
|
||||
type wrappedAuthenticatedHandler struct {
|
||||
handleFunc http.HandlerFunc
|
||||
read Permission
|
||||
write Permission
|
||||
}
|
||||
http.HandlerFunc
|
||||
|
||||
// ServeHTTP handles the http request.
|
||||
func (wah *wrappedAuthenticatedHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
wah.handleFunc(w, r)
|
||||
read Permission
|
||||
write Permission
|
||||
}
|
||||
|
||||
// ReadPermission returns the read permission for the handler.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue