@Override public URI uri() { return this.request.uri(); }
@Override public URI uri() { return this.delegate.uri(); }
/** * Get the request path. */ default String path() { return uri().getRawPath(); }
@Test public void uri() { URI uri = URI.create("https://example.com"); when(mockRequest.uri()).thenReturn(uri); assertSame(uri, wrapper.uri()); }
public DefaultServerRequestBuilder(ServerRequest other) { Assert.notNull(other, "ServerRequest must not be null"); this.messageReaders = other.messageReaders(); this.exchange = other.exchange(); this.methodName = other.methodName(); this.uri = other.uri(); headers(headers -> headers.addAll(other.headers().asHttpHeaders())); cookies(cookies -> cookies.addAll(other.cookies())); attributes(attributes -> attributes.putAll(other.attributes())); }
@Override public URI uri() { return this.request.uri(); }
@Override public URI uri() { return this.request.uri(); }
/** * Return the request path. */ default String path() { return uri().getPath(); }
private String getBaseUrl(final ServerRequest request) { final URI uri = request.uri(); final int last = uri.toString().length() - request.path().length(); return uri.toString().substring(0, last); }
@Bean HandlerFunction<ServerResponse> fallbackHandler() { return request -> { final URL url = Try.of(() -> request.uri().toURL()) .getOrElseThrow(() -> new RuntimeException("=/")); final String protocol = url.getProtocol(); final int defaultPort = "https".equals(protocol) ? 443 : 80; final int currentPort = url.getPort(); final int port = currentPort == -1 ? defaultPort : currentPort; final String baseUrl = format("%s://%s:%d", protocol, url.getHost(), port); return ok().body(Flux.just( format("GET orders -> %s/api/orders/", baseUrl), format("GET pages -> %s/api/", baseUrl), format("GET ** -> %s/", baseUrl) ), String.class); }; }