@Test public void no_routes_always_throws_NoServiceConfiguredException() throws Exception { PathPrefixRouter router = buildRouter(emptyMap()); assertThrows(NoServiceConfiguredException.class, () -> Mono.from(router.handle(LiveHttpRequest.get("/").build(), null)).block() ); }
@Override public Eventual<LiveHttpResponse> handle(LiveHttpRequest request, HttpInterceptor.Context context) { String path = request.path(); for (PrefixRoute route : routes) { if (path.startsWith(route.prefix)) { return route.routingObject.handle(request, context); } } return Eventual.error(new NoServiceConfiguredException(path)); }
PathPrefixRouter implements RoutingObject { @Override public Eventual<LiveHttpResponse> handle(LiveHttpRequest request, HttpInterceptor.Context context) { String path = request.path(); for (PrefixRoute route : routes) { if (path.startsWith(route.prefix)) { return route.routingObject.handle(request, context); } } return Eventual.error(new NoServiceConfiguredException(path)); } }
PathPrefixRouter implements RoutingObject { @Override public Eventual<LiveHttpResponse> handle(LiveHttpRequest request, HttpInterceptor.Context context) { String path = request.path(); for (PrefixRoute route : routes) { if (path.startsWith(route.prefix)) { return route.routingObject.handle(request, context); } } return Eventual.error(new NoServiceConfiguredException(path)); } PathPrefixRouter(PrefixRoute[] routes); }
PathPrefixRouter implements RoutingObject { @Override public Eventual<LiveHttpResponse> handle(LiveHttpRequest request, HttpInterceptor.Context context) { String path = request.path(); for (PrefixRoute route : routes) { if (path.startsWith(route.prefix)) { return route.routingObject.handle(request, context); } } return Eventual.error(new NoServiceConfiguredException(path)); } PathPrefixRouter(PrefixRoute[] routes); @Override Eventual<LiveHttpResponse> handle(LiveHttpRequest request, HttpInterceptor.Context context); @Override CompletableFuture<Void> stop(); }
PathPrefixRouter implements RoutingObject { @Override public Eventual<LiveHttpResponse> handle(LiveHttpRequest request, HttpInterceptor.Context context) { String path = request.path(); for (PrefixRoute route : routes) { if (path.startsWith(route.prefix)) { return route.routingObject.handle(request, context); } } return Eventual.error(new NoServiceConfiguredException(path)); } PathPrefixRouter(PrefixRoute[] routes); @Override Eventual<LiveHttpResponse> handle(LiveHttpRequest request, HttpInterceptor.Context context); @Override CompletableFuture<Void> stop(); static final Schema.FieldType SCHEMA; }