@Override
    public CapabilitySet requiredCapabilities(RequestView req) {
        Path pathMatcher = new Path(req.uri());
        Route route = resolveRoute(pathMatcher);
        HandlerHolder<?> handler = resolveHandler(req.method(), route);
        return Optional.ofNullable(handler.config.requiredCapabilities)
                .or(() -> Optional.ofNullable(route.requiredCapabilities))
                .or(() -> Optional.ofNullable(requiredCapabilities))
                .orElse(DEFAULT_REQUIRED_CAPABILITIES);
    }
@Test
    void resolves_correct_capabilities() {
        var restApi = RestApi.builder()
                .requiredCapabilities(Capability.CONTENT__METRICS_API)
                .addRoute(route("/api1")
                                  .requiredCapabilities(Capability.CONTENT__SEARCH_API)
                                  .get(ctx -> new MessageResponse(ctx.aclAction().name()),
                                       handlerConfig().withRequiredCapabilities(Capability.SLOBROK__API))
                                  .post(ctx -> new MessageResponse(ctx.aclAction().name())))
                .addRoute(route("/api2")
                                  .get(ctx -> new MessageResponse(ctx.aclAction().name()))
                                  .post(ctx -> new MessageResponse(ctx.aclAction().name()),
                                        handlerConfig().withRequiredCapabilities(Capability.CONTENT__DOCUMENT_API)))
                .build();
        assertRequiredCapability(restApi, Method.GET, "/api1", Capability.SLOBROK__API);
        assertRequiredCapability(restApi, Method.POST, "/api1", Capability.CONTENT__SEARCH_API);
        assertRequiredCapability(restApi, Method.GET, "/api2", Capability.CONTENT__METRICS_API);
        assertRequiredCapability(restApi, Method.POST, "/api2", Capability.CONTENT__DOCUMENT_API);
    }