adminAuthHandler does some standard checks for admin endpoints. It returns if something is wrong. Otherwise, it lets the given handler serve the request.
(next http.Handler)
| 51 | // adminAuthHandler does some standard checks for admin endpoints. |
| 52 | // It returns if something is wrong. Otherwise, it lets the given handler serve the request. |
| 53 | func adminAuthHandler(next http.Handler) http.Handler { |
| 54 | return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { |
| 55 | if !hasPoormansAuth(r) { |
| 56 | x.AddCorsHeaders(w) |
| 57 | x.SetStatus(w, x.ErrorUnauthorized, "Invalid X-Dgraph-AuthToken") |
| 58 | return |
| 59 | } |
| 60 | |
| 61 | next.ServeHTTP(w, r) |
| 62 | }) |
| 63 | } |
| 64 | |
| 65 | func getAdminMux() *http.ServeMux { |
| 66 | adminMux := http.NewServeMux() |
no test coverage detected