(token string, next http.Handler)
| 43 | } |
| 44 | |
| 45 | func authMiddleware(token string, next http.Handler) http.Handler { |
| 46 | return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { |
| 47 | auth := r.Header.Get("Authorization") |
| 48 | if auth != "Bearer "+token { |
| 49 | http.Error(w, "Unauthorized", http.StatusUnauthorized) |
| 50 | return |
| 51 | } |
| 52 | next.ServeHTTP(w, r) |
| 53 | }) |
| 54 | } |
no test coverage detected