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