Introduce ServerRequest.methodName()
This commit introduces a methodName() method to the ServerRequest, returning the String name of the method. This method is useful for non-standard HTTP methods.
This commit is contained in:
parent
1bc93e3d0f
commit
2fb3eeba6f
|
|
@ -109,6 +109,11 @@ public class MockServerRequest implements ServerRequest {
|
|||
return this.method;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String methodName() {
|
||||
return this.method.name();
|
||||
}
|
||||
|
||||
@Override
|
||||
public URI uri() {
|
||||
return this.uri;
|
||||
|
|
|
|||
|
|
@ -35,7 +35,6 @@ 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;
|
||||
|
|
@ -83,10 +82,9 @@ class DefaultServerRequest implements ServerRequest {
|
|||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public HttpMethod method() {
|
||||
return request().getMethod();
|
||||
public String methodName() {
|
||||
return request().getMethodValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -476,6 +476,11 @@ public abstract class RequestPredicates {
|
|||
return this.request.method();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String methodName() {
|
||||
return this.request.methodName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public URI uri() {
|
||||
return this.request.uri();
|
||||
|
|
|
|||
|
|
@ -59,9 +59,19 @@ public interface ServerRequest {
|
|||
|
||||
/**
|
||||
* Return the HTTP method.
|
||||
* @return the HTTP method as an HttpMethod enum value, or {@code null}
|
||||
* if not resolvable (e.g. in case of a non-standard HTTP method)
|
||||
*/
|
||||
@Nullable
|
||||
HttpMethod method();
|
||||
default HttpMethod method() {
|
||||
return HttpMethod.resolve(methodName());
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the name of the HTTP method.
|
||||
* @return the HTTP method as a String
|
||||
*/
|
||||
String methodName();
|
||||
|
||||
/**
|
||||
* Return the request URI.
|
||||
|
|
|
|||
|
|
@ -79,6 +79,11 @@ public class ServerRequestWrapper implements ServerRequest {
|
|||
return this.delegate.method();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String methodName() {
|
||||
return this.delegate.methodName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public URI uri() {
|
||||
return this.delegate.uri();
|
||||
|
|
|
|||
|
|
@ -108,6 +108,11 @@ public class MockServerRequest implements ServerRequest {
|
|||
return this.method;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String methodName() {
|
||||
return this.method.name();
|
||||
}
|
||||
|
||||
@Override
|
||||
public URI uri() {
|
||||
return this.uri;
|
||||
|
|
|
|||
Loading…
Reference in New Issue