org.springframework.web.reactive.function.server.support.ServerRequestWrapper Maven / Gradle / Ivy
/*
* Copyright 2002-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.web.reactive.function.server.support;
import java.net.InetSocketAddress;
import java.net.URI;
import java.nio.charset.Charset;
import java.security.Principal;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Optional;
import java.util.OptionalLong;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
import org.springframework.core.ParameterizedTypeReference;
import org.springframework.http.HttpCookie;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.http.HttpRange;
import org.springframework.http.MediaType;
import org.springframework.http.codec.HttpMessageReader;
import org.springframework.http.codec.multipart.Part;
import org.springframework.http.server.PathContainer;
import org.springframework.http.server.reactive.ServerHttpRequest;
import org.springframework.util.Assert;
import org.springframework.util.MultiValueMap;
import org.springframework.web.reactive.function.BodyExtractor;
import org.springframework.web.reactive.function.server.ServerRequest;
import org.springframework.web.server.ServerWebExchange;
import org.springframework.web.server.WebSession;
import org.springframework.web.util.UriBuilder;
/**
* Implementation of the {@link ServerRequest} interface that can be subclassed
* to adapt the request in a
* {@link org.springframework.web.reactive.function.server.HandlerFilterFunction handler filter function}.
* All methods default to calling through to the wrapped request.
*
* @author Arjen Poutsma
* @since 5.0
*/
public class ServerRequestWrapper implements ServerRequest {
private final ServerRequest delegate;
/**
* Create a new {@code ServerRequestWrapper} that wraps the given request.
* @param delegate the request to wrap
*/
public ServerRequestWrapper(ServerRequest delegate) {
Assert.notNull(delegate, "Delegate must not be null");
this.delegate = delegate;
}
/**
* Return the wrapped request.
*/
public ServerRequest request() {
return this.delegate;
}
@Override
public HttpMethod method() {
return this.delegate.method();
}
@Override
public String methodName() {
return this.delegate.methodName();
}
@Override
public URI uri() {
return this.delegate.uri();
}
@Override
public UriBuilder uriBuilder() {
return this.delegate.uriBuilder();
}
@Override
public String path() {
return this.delegate.path();
}
@Override
public PathContainer pathContainer() {
return this.delegate.pathContainer();
}
@Override
public Headers headers() {
return this.delegate.headers();
}
@Override
public MultiValueMap cookies() {
return this.delegate.cookies();
}
@Override
public Optional remoteAddress() {
return this.delegate.remoteAddress();
}
@Override
public List> messageReaders() {
return this.delegate.messageReaders();
}
@Override
public T body(BodyExtractor extractor) {
return this.delegate.body(extractor);
}
@Override
public T body(BodyExtractor extractor, Map hints) {
return this.delegate.body(extractor, hints);
}
@Override
public Mono bodyToMono(Class elementClass) {
return this.delegate.bodyToMono(elementClass);
}
@Override
public Mono bodyToMono(ParameterizedTypeReference typeReference) {
return this.delegate.bodyToMono(typeReference);
}
@Override
public Flux bodyToFlux(Class elementClass) {
return this.delegate.bodyToFlux(elementClass);
}
@Override
public Flux bodyToFlux(ParameterizedTypeReference typeReference) {
return this.delegate.bodyToFlux(typeReference);
}
@Override
public Optional