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;
|
return this.method;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String methodName() {
|
||||||
|
return this.method.name();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public URI uri() {
|
public URI uri() {
|
||||||
return this.uri;
|
return this.uri;
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,6 @@ import reactor.core.publisher.Mono;
|
||||||
import org.springframework.core.ParameterizedTypeReference;
|
import org.springframework.core.ParameterizedTypeReference;
|
||||||
import org.springframework.http.HttpCookie;
|
import org.springframework.http.HttpCookie;
|
||||||
import org.springframework.http.HttpHeaders;
|
import org.springframework.http.HttpHeaders;
|
||||||
import org.springframework.http.HttpMethod;
|
|
||||||
import org.springframework.http.HttpRange;
|
import org.springframework.http.HttpRange;
|
||||||
import org.springframework.http.MediaType;
|
import org.springframework.http.MediaType;
|
||||||
import org.springframework.http.codec.HttpMessageReader;
|
import org.springframework.http.codec.HttpMessageReader;
|
||||||
|
|
@ -83,10 +82,9 @@ class DefaultServerRequest implements ServerRequest {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public HttpMethod method() {
|
public String methodName() {
|
||||||
return request().getMethod();
|
return request().getMethodValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -476,6 +476,11 @@ public abstract class RequestPredicates {
|
||||||
return this.request.method();
|
return this.request.method();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String methodName() {
|
||||||
|
return this.request.methodName();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public URI uri() {
|
public URI uri() {
|
||||||
return this.request.uri();
|
return this.request.uri();
|
||||||
|
|
|
||||||
|
|
@ -59,9 +59,19 @@ public interface ServerRequest {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the HTTP method.
|
* 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
|
@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.
|
* Return the request URI.
|
||||||
|
|
|
||||||
|
|
@ -79,6 +79,11 @@ public class ServerRequestWrapper implements ServerRequest {
|
||||||
return this.delegate.method();
|
return this.delegate.method();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String methodName() {
|
||||||
|
return this.delegate.methodName();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public URI uri() {
|
public URI uri() {
|
||||||
return this.delegate.uri();
|
return this.delegate.uri();
|
||||||
|
|
|
||||||
|
|
@ -108,6 +108,11 @@ public class MockServerRequest implements ServerRequest {
|
||||||
return this.method;
|
return this.method;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String methodName() {
|
||||||
|
return this.method.name();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public URI uri() {
|
public URI uri() {
|
||||||
return this.uri;
|
return this.uri;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue