first round of files

This commit is contained in:
2026-05-06 23:13:06 +02:00
parent a30962474d
commit 2aa5d01307
24 changed files with 991 additions and 0 deletions
+16
View File
@@ -0,0 +1,16 @@
package middleware
import (
"net/http"
)
func RequireAdmin(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
isAdmin, _ := r.Context().Value(ContextKeyIsAdmin).(bool)
if !isAdmin {
http.Error(w, "forbidden", http.StatusForbidden)
return
}
next.ServeHTTP(w, r)
})
}