lens @ c3ea735c0f03a0827a8e753a5b5adf6e31f4c925

 1package view
 2
 3import (
 4	"net/http"
 5
 6	"git.sr.ht/~gabrielgio/img/pkg/ext"
 7)
 8
 9type View interface {
10	SetMyselfIn(r *ext.Router)
11}
12
13func Protect(next ext.ErrorRequestHandler) ext.ErrorRequestHandler {
14	return func(w http.ResponseWriter, r *http.Request) error {
15		user := ext.GetUserFromCtx(r)
16		if !user.IsAdmin {
17			http.NotFound(w, r)
18			return nil
19		}
20		return next(w, r)
21	}
22}