Java Code Examples for org.springframework.http.HttpMethod#matches()
The following examples show how to use
org.springframework.http.HttpMethod#matches() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CorsConfiguration.java From spring4-understanding with Apache License 2.0 | 6 votes |
/** * Check the HTTP request method (or the method from the * {@code Access-Control-Request-Method} header on a pre-flight request) * against the configured allowed methods. * @param requestMethod the HTTP request method to check * @return the list of HTTP methods to list in the response of a pre-flight * request, or {@code null} if the supplied {@code requestMethod} is not allowed */ public List<HttpMethod> checkHttpMethod(HttpMethod requestMethod) { if (requestMethod == null) { return null; } List<String> allowedMethods = (this.allowedMethods != null ? this.allowedMethods : new ArrayList<String>()); if (allowedMethods.contains(ALL)) { return Collections.singletonList(requestMethod); } if (allowedMethods.isEmpty()) { allowedMethods.add(HttpMethod.GET.name()); } List<HttpMethod> result = new ArrayList<HttpMethod>(allowedMethods.size()); boolean allowed = false; for (String method : allowedMethods) { if (requestMethod.matches(method)) { allowed = true; } HttpMethod resolved = HttpMethod.resolve(method); if (resolved != null) { result.add(resolved); } } return (allowed ? result : null); }
Example 2
Source File: RequestMethodsRequestCondition.java From spring-analysis-note with MIT License | 5 votes |
@Nullable private RequestMethodsRequestCondition matchRequestMethod(String httpMethodValue) { HttpMethod httpMethod = HttpMethod.resolve(httpMethodValue); if (httpMethod != null) { for (RequestMethod method : getMethods()) { if (httpMethod.matches(method.name())) { return requestMethodConditionCache.get(method.name()); } } if (httpMethod == HttpMethod.HEAD && getMethods().contains(RequestMethod.GET)) { return requestMethodConditionCache.get(HttpMethod.GET.name()); } } return null; }
Example 3
Source File: RequestMethodsRequestCondition.java From java-technology-stack with MIT License | 5 votes |
@Nullable private RequestMethodsRequestCondition matchRequestMethod(@Nullable HttpMethod httpMethod) { if (httpMethod != null) { for (RequestMethod method : getMethods()) { if (httpMethod.matches(method.name())) { return new RequestMethodsRequestCondition(method); } } if (httpMethod == HttpMethod.HEAD && getMethods().contains(RequestMethod.GET)) { return GET_CONDITION; } } return null; }
Example 4
Source File: RequestMethodsRequestCondition.java From java-technology-stack with MIT License | 5 votes |
@Nullable private RequestMethodsRequestCondition matchRequestMethod(String httpMethodValue) { HttpMethod httpMethod = HttpMethod.resolve(httpMethodValue); if (httpMethod != null) { for (RequestMethod method : getMethods()) { if (httpMethod.matches(method.name())) { return new RequestMethodsRequestCondition(method); } } if (httpMethod == HttpMethod.HEAD && getMethods().contains(RequestMethod.GET)) { return GET_CONDITION; } } return null; }
Example 5
Source File: RequestMethodsRequestCondition.java From lams with GNU General Public License v2.0 | 5 votes |
private RequestMethodsRequestCondition matchRequestMethod(String httpMethodValue) { HttpMethod httpMethod = HttpMethod.resolve(httpMethodValue); if (httpMethod != null) { for (RequestMethod method : getMethods()) { if (httpMethod.matches(method.name())) { return new RequestMethodsRequestCondition(method); } } if (httpMethod == HttpMethod.HEAD && getMethods().contains(RequestMethod.GET)) { return GET_CONDITION; } } return null; }