Skip to content

Commit

Permalink
added builder for the root route and removed routes visitor as the ro…
Browse files Browse the repository at this point in the history
…ute can be created with customized sub-route directly.

Signed-off-by: Johannes Schneider <johannes.schneider@bosch-si.com>
  • Loading branch information
Johannes Schneider committed Jan 8, 2019
1 parent 7048845 commit b6f6e9c
Show file tree
Hide file tree
Showing 9 changed files with 717 additions and 332 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public DittoGatewayAuthenticationDirectiveFactory(final Config config,
}

@Override
public GatewayAuthenticationDirective buildRestApiAuthentication() {
public GatewayAuthenticationDirective buildHttpAuthentication() {
return gatewayAuthenticationDirective;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,14 @@
public interface GatewayAuthenticationDirectiveFactory {

/**
* Builds the {@link GatewayAuthenticationDirective authentication directive} that should be used for the REST api.
* Builds the {@link GatewayAuthenticationDirective authentication directive} that should be used for HTTP API.
*
* @return The built {@link GatewayAuthenticationDirective authentication directive}.
*/
GatewayAuthenticationDirective buildRestApiAuthentication();
GatewayAuthenticationDirective buildHttpAuthentication();

/**
* Builds the {@link GatewayAuthenticationDirective authentication directive} that should be used for web socket
* connections.
* Builds the {@link GatewayAuthenticationDirective authentication directive} that should be used for WebSocket API.
*
* @return The built {@link GatewayAuthenticationDirective authentication directive}.
*/
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,197 @@
/*
* Copyright (c) 2017-2018 Bosch Software Innovations GmbH.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/org/documents/epl-2.0/index.php
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.eclipse.ditto.services.gateway.endpoints.routes;

import java.util.List;

import org.eclipse.ditto.protocoladapter.HeaderTranslator;
import org.eclipse.ditto.services.gateway.endpoints.directives.auth.GatewayAuthenticationDirective;
import org.eclipse.ditto.services.gateway.endpoints.routes.devops.DevOpsRoute;
import org.eclipse.ditto.services.gateway.endpoints.routes.health.CachingHealthRoute;
import org.eclipse.ditto.services.gateway.endpoints.routes.policies.PoliciesRoute;
import org.eclipse.ditto.services.gateway.endpoints.routes.sse.SseThingsRoute;
import org.eclipse.ditto.services.gateway.endpoints.routes.stats.StatsRoute;
import org.eclipse.ditto.services.gateway.endpoints.routes.status.OverallStatusRoute;
import org.eclipse.ditto.services.gateway.endpoints.routes.things.ThingsRoute;
import org.eclipse.ditto.services.gateway.endpoints.routes.thingsearch.ThingSearchRoute;
import org.eclipse.ditto.services.gateway.endpoints.routes.websocket.WebsocketRoute;
import org.eclipse.ditto.services.utils.health.routes.StatusRoute;
import org.eclipse.ditto.services.utils.protocol.ProtocolAdapterProvider;

import akka.http.javadsl.server.ExceptionHandler;
import akka.http.javadsl.server.RejectionHandler;
import akka.http.javadsl.server.Route;

/**
* A builder for the root {@code Route}.
*/
public interface RootRouteBuilder {

/**
* Sets the status sub-route.
*
* @param route the route to set.
* @return the Builder to allow method chaining.
*/
RootRouteBuilder statusRoute(StatusRoute route);

/**
* Sets the overall status sub-route.
*
* @param route the route to set.
* @return the Builder to allow method chaining.
*/
RootRouteBuilder overallStatusRoute(OverallStatusRoute route);

/**
* Sets the caching health sub-route.
*
* @param route the route to set.
* @return the Builder to allow method chaining.
*/
RootRouteBuilder cachingHealthRoute(CachingHealthRoute route);

/**
* Sets the devops sub-route.
*
* @param route the route to set.
* @return the Builder to allow method chaining.
*/
RootRouteBuilder devopsRoute(DevOpsRoute route);

/**
* Sets the policies sub-route.
*
* @param route the route to set.
* @return the Builder to allow method chaining.
*/
RootRouteBuilder policiesRoute(PoliciesRoute route);

/**
* Sets the sse things sub-route.
*
* @param route the route to set.
* @return the Builder to allow method chaining.
*/
RootRouteBuilder sseThingsRoute(SseThingsRoute route);

/**
* Sets the things sub-route.
*
* @param route the route to set.
* @return the Builder to allow method chaining.
*/
RootRouteBuilder thingsRoute(ThingsRoute route);

/**
* Sets the thing search sub-route.
*
* @param route the route to set.
* @return the Builder to allow method chaining.
*/
RootRouteBuilder thingSearchRoute(ThingSearchRoute route);

/**
* Sets the websocket sub-route.
*
* @param route the route to set.
* @return the Builder to allow method chaining.
*/
RootRouteBuilder websocketRoute(WebsocketRoute route);

/**
* Sets the stats sub-route.
*
* @param route the route to set.
* @return the Builder to allow method chaining.
*/
RootRouteBuilder statsRoute(StatsRoute route);

/**
* Sets the http authentication directive.
*
* @param directive the directive to set.
* @return the Builder to allow method chaining.
*/
RootRouteBuilder httpAuthenticationDirective(GatewayAuthenticationDirective directive);

/**
* Sets the websocket authentication directive.
*
* @param directive the directive to set.
* @return the Builder to allow method chaining.
*/
RootRouteBuilder wsAuthenticationDirective(GatewayAuthenticationDirective directive);

/**
* Sets the supported api versions.
*
* @param versions the versions to set.
* @return the Builder to allow method chaining.
*/
RootRouteBuilder supportedSchemaVersions(List<Integer> versions);

/**
* Sets the protocol adapter provider.
*
* @param provider the provider to set.
* @return the Builder to allow method chaining.
*/
RootRouteBuilder protocolAdapterProvider(ProtocolAdapterProvider provider);

/**
* Sets the header translator.
*
* @param translator the translator to set.
* @return the Builder to allow method chaining.
*/
RootRouteBuilder headerTranslator(HeaderTranslator translator);

/**
* Sets the custom api routes provider.
*
* @param provider the provider to set.
* @return the Builder to allow method chaining.
*/
RootRouteBuilder customApiRoutesProvider(CustomApiRoutesProvider provider);

/**
* Sets the custom headers handler.
*
* @param handler the handler to set.
* @return the Builder to allow method chaining.
*/
RootRouteBuilder customHeadersHandler(CustomHeadersHandler handler);

/**
* Sets the exception handler.
*
* @param handler the handler to set.
* @return the Builder to allow method chaining.
*/
RootRouteBuilder exceptionHandler(ExceptionHandler handler);

/**
* Sets the rejection handler.
*
* @param handler the handler to set.
* @return the Builder to allow method chaining.
*/
RootRouteBuilder rejectionHandler(RejectionHandler handler);

/**
* Builds the root route.
*
* @return the route.
*/
Route build();

}
Loading

0 comments on commit b6f6e9c

Please sign in to comment.