| 2787 | |
| 2788 | |
| 2789 | Future<Response> Http::containers( |
| 2790 | const Request& request, |
| 2791 | const Option<Principal>& principal) const |
| 2792 | { |
| 2793 | // TODO(a10gupta): Remove check for enabled |
| 2794 | // authorization as part of MESOS-5346. |
| 2795 | if (request.method != "GET" && slave->authorizer.isSome()) { |
| 2796 | return MethodNotAllowed({"GET"}, request.method); |
| 2797 | } |
| 2798 | |
| 2799 | Try<string> endpoint = extractEndpoint(request.url); |
| 2800 | if (endpoint.isError()) { |
| 2801 | return Failure("Failed to extract endpoint: " + endpoint.error()); |
| 2802 | } |
| 2803 | |
| 2804 | return authorizeEndpoint( |
| 2805 | endpoint.get(), |
| 2806 | request.method, |
| 2807 | slave->authorizer, |
| 2808 | principal) |
| 2809 | .then(defer( |
| 2810 | slave->self(), |
| 2811 | [this, request, principal](bool authorized) -> Future<Response> { |
| 2812 | if (!authorized) { |
| 2813 | return Forbidden(); |
| 2814 | } |
| 2815 | |
| 2816 | return _containers(request, principal); |
| 2817 | })); |
| 2818 | } |
| 2819 | |
| 2820 | |
| 2821 | Future<Response> Http::getContainers( |
no test coverage detected