FnRequestHandler extends
	SimpleRequestHandler<FnRequestHandler.WrappedInput, FnRequestHandler.WrappedOutput> { public RequestAndBaseUri getRequestAndBaseUri(InputEvent inputEvent) { URI baseUri; String route = inputEvent.getRoute(); URI requestUri = URI.create(inputEvent.getRequestUrl()); String path = requestUri.getPath(); if (!path.endsWith(route)) { throw new IllegalStateException("Should have a valid route in the Uri"); } String split = path.substring(0, path.length() - route.length()); baseUri = UriBuilder.fromUri(requestUri).replacePath(split + "/").replaceQuery(null).build(); return new RequestAndBaseUri(baseUri, requestUri); }  @Override JRestlessContainerRequest createContainerRequest(WrappedInput wrappedInput); RequestAndBaseUri getRequestAndBaseUri(InputEvent inputEvent); @FnConfiguration void setRuntimeContext(RuntimeContext rctx); final OutputEvent handleRequest(InputEvent inputEvent);  }
@Test public void getRequestAndBaseUri_RouteDiffersInURL_ShouldThrowException() { InputEvent inputEvent = new DefaultInputEvent() .setReqUrlAndRoute(DOMAIN_WITH_SCHEME + "/r/route", "/invalidRoute") .getInputEvent(); assertThrows(IllegalStateException.class, () -> requestHandler.getRequestAndBaseUri(inputEvent)); }
@Test public void getRequestAndBaseUri_ShouldGetCorrectBaseAndReqUri() { Map<String, List<String>> params = ImmutableMap.of("query", Collections.singletonList("params")); InputEvent inputEvent = new DefaultInputEvent() .setReqUrlAndRoute(DOMAIN_WITH_SCHEME +"/r/route?query=params","/route") .setQueryParameters(params) .getInputEvent(); RequestAndBaseUri requestAndBaseUri = requestHandler.getRequestAndBaseUri(inputEvent); assertEquals(URI.create(DOMAIN_WITH_SCHEME +"/r/route?query=params"), requestAndBaseUri.getRequestUri()); assertEquals(URI.create(DOMAIN_WITH_SCHEME + "/r/"), requestAndBaseUri.getBaseUri()); }