(next http.Handler)
| 7 | ) |
| 8 | |
| 9 | func EnsureAdmin(next http.Handler) http.Handler { |
| 10 | return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { |
| 11 | log.Println("Checking if user is admin") |
| 12 | if !strings.Contains(r.Header.Get("Authorization"), "Admin") { |
| 13 | w.WriteHeader(http.StatusUnauthorized) |
| 14 | w.Write([]byte(http.StatusText(http.StatusUnauthorized))) |
| 15 | return |
| 16 | } |
| 17 | next.ServeHTTP(w, r) |
| 18 | }) |
| 19 | } |
| 20 | |
| 21 | func LoadUser(next http.Handler) http.Handler { |
| 22 | return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { |
nothing calls this directly
no test coverage detected