lens @ a9a270ba1e1e9add10d75de3e592efee9728c5b4

 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}