RequireAuth wraps a function with another function that enforces HTTP Basic Auth and checks if the operations in op are all permitted.
(h http.Handler, op Operation)
| 432 | // RequireAuth wraps a function with another function that enforces |
| 433 | // HTTP Basic Auth and checks if the operations in op are all permitted. |
| 434 | func RequireAuth(h http.Handler, op Operation) http.Handler { |
| 435 | return http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) { |
| 436 | if Allowed(req, op) { |
| 437 | h.ServeHTTP(rw, req) |
| 438 | } else { |
| 439 | SendUnauthorized(rw, req) |
| 440 | } |
| 441 | }) |
| 442 | } |
| 443 | |
| 444 | var ( |
| 445 | processRand string |
no test coverage detected