/** * Builds the {@code /health} route. * * @return the {@code /health} route. */ public Route buildHealthRoute() { return path(PATH_HEALTH, () -> // /health get(() -> // GET completeWithFuture(createOverallHealthResponse()) ) ); }
/** * 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 /search} route. * * @return the {@code /search}} route. */ public Route buildSearchRoute(final RequestContext ctx, final DittoHeaders dittoHeaders) { return Directives.rawPathPrefix(CustomPathMatchers.mergeDoubleSlashes().concat(PATH_SEARCH), () -> Directives.rawPathPrefix(CustomPathMatchers.mergeDoubleSlashes().concat(PATH_THINGS), () -> // /search/things Directives.route( // /search/things/count path(PATH_COUNT, () -> countThings(ctx, dittoHeaders)), // /search/things pathEndOrSingleSlash(() -> searchThings(ctx, dittoHeaders)) ) ) ); }
/** * 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 buildOverallStatusRoute() { return rawPathPrefix(mergeDoubleSlashes().concat(PATH_OVERALL), () -> // /overall/* authenticateDevopsBasic(REALM_DEVOPS, get(() -> // GET // /overall/status // /overall/status/health // /overall/status/cluster rawPathPrefix(mergeDoubleSlashes().concat(PATH_STATUS), () -> route( // /status pathEndOrSingleSlash( () -> completeWithFuture(createOverallStatusResponse())), // /status/health path(PATH_HEALTH, () -> completeWithFuture(createOverallHealthResponse())), path(PATH_CLUSTER, () -> complete( // /status/cluster HttpResponse.create().withStatus(StatusCodes.OK) .withEntity(ContentTypes.APPLICATION_JSON, clusterStateSupplier.get().toJson().toString())) ) )) ))); }
private Route thingsEntryPolicyId(final RequestContext ctx, final DittoHeaders dittoHeaders, final String thingId) { return path(PATH_POLICY_ID, () -> // /things/<thingId>/policyId route( get(() -> // GET /things/<thingId>/policyId handlePerRequest(ctx, RetrievePolicyId.of(thingId, dittoHeaders)) ), put(() -> // GET /things/<thingId>/policyId extractDataBytes(payloadSource -> handlePerRequest(ctx, dittoHeaders, payloadSource, policyIdJson -> ModifyPolicyId.of(thingId, Optional.of(JsonFactory.readFrom(policyIdJson)) .filter(JsonValue::isString) .map(JsonValue::asString) .orElse(policyIdJson), dittoHeaders) ) ) ) ) ); }
private Route buildSubRoutes(final RequestContext ctx, final String correlationId) { return route( pathPrefix(THINGS_PATH, () -> // /stats/things route( path(DETAILS_PATH, () -> authenticateDevopsBasic(REALM_DEVOPS, handleDevOpsPerRequest(ctx, RetrieveStatisticsDetails.of( buildDevOpsDittoHeaders(correlationId)))) ), pathEndOrSingleSlash(() -> handleDevOpsPerRequest(ctx, RetrieveStatistics.of( buildDevOpsDittoHeaders(correlationId))) ) ) ), path(SEARCH_PATH, () -> // /stats/search handleSudoCountThingsPerRequest(ctx, SudoCountThings.of( buildDevOpsDittoHeaders(correlationId))) ) ); }
path(segment("products").slash(longSegment()), (productId) ->