private Route buildApiSubRoutes(final RequestContext ctx, final DittoHeaders dittoHeaders, final AuthorizationContext authorizationContext) { final Route customApiSubRoutes = customApiRoutesProvider.authorized(dittoHeaders); return Directives.route( // /api/{apiVersion}/policies policiesRoute.buildPoliciesRoute(ctx, dittoHeaders), // /api/{apiVersion}/things SSE support sseThingsRoute.buildThingsSseRoute(ctx, () -> overwriteDittoHeaders(ctx, dittoHeaders, CustomHeadersHandler.RequestType.SSE, authorizationContext)), // /api/{apiVersion}/things thingsRoute.buildThingsRoute(ctx, dittoHeaders), // /api/{apiVersion}/search/things thingSearchRoute.buildSearchRoute(ctx, dittoHeaders) ).orElse(customApiSubRoutes); }
/** * Builds the {@code /status} route. * * @return the {@code /status} route. */ public Route buildStatusRoute() { return pathPrefix(PATH_STATUS, () -> // /status/* get(() -> // GET route( pathEndOrSingleSlash(() -> // /status complete( HttpResponse.create().withStatus(StatusCodes.OK) .withEntity(ContentTypes.APPLICATION_JSON, Status.provideStaticStatus().toString()) ) ), path(PATH_HEALTH, healthRouteSupplier), // /status/health path(PATH_CLUSTER, () -> complete( // /status/cluster HttpResponse.create().withStatus(StatusCodes.OK) .withEntity(ContentTypes.APPLICATION_JSON, clusterStateSupplier.get().toJson().toString())) ) ) ).orElse(complete(StatusCodes.METHOD_NOT_ALLOWED))); }
/** * Builds the {@code /status} route. * * @return the {@code /status} route. */ public Route buildStatusRoute() { return pathPrefix(PATH_STATUS, () -> // /status/* get(() -> // GET route( pathEndOrSingleSlash(() -> // /status complete( HttpResponse.create().withStatus(StatusCodes.OK) .withEntity(ContentTypes.APPLICATION_JSON, Status.provideStaticStatus().toString()) ) ), path(PATH_HEALTH, healthRouteSupplier), // /status/health path(PATH_CLUSTER, () -> complete( // /status/cluster HttpResponse.create().withStatus(StatusCodes.OK) .withEntity(ContentTypes.APPLICATION_JSON, clusterStateSupplier.get().toJson().toString())) ) ) ).orElse(complete(StatusCodes.METHOD_NOT_ALLOWED))); }
private Route api(final RequestContext ctx, final String correlationId) { return rawPathPrefix(mergeDoubleSlashes().concat(HTTP_PATH_API_PREFIX), () -> // /api customApiRoutesProvider.unauthorized(apiVersion, correlationId).orElse( apiAuthentication(correlationId, authContextWithPrefixedSubjects ->
).orElse( // GET /things/<thingId>/attributes/<attributePointerStr> extractUnmatchedPath(attributePointerStr -> handlePerRequest(ctx, RetrieveAttribute attributesJson), dittoHeaders)) ).orElse( // PUT /things/<thingId>/attributes/<attributePointerStr> extractUnmatchedPath(attributePointerStr -> handlePerRequest(ctx, dittoHeaders, payloadSource, ).orElse( // DELETE /things/<thingId>/attributes/<attributePointerStr> extractUnmatchedPath(attributePointerStr -> handlePerRequest(ctx, DeleteAttribute