private boolean isParameterTokenSupportedForRequest(ServerHttpRequest request) { return this.allowUriQueryParameter && HttpMethod.GET.equals(request.getMethod()); } }
public static ExchangeFilterFunction retry(int defaultRetries, Map<String, Integer> retriesPerEndpoint) { return (request, next) -> { int retries = 0; if (!request.method().equals(HttpMethod.DELETE) && !request.method().equals(HttpMethod.PATCH) && !request.method().equals(HttpMethod.POST) && !request.method().equals(HttpMethod.PUT)) { retries = request.attribute(ATTRIBUTE_ENDPOINT).map(retriesPerEndpoint::get).orElse(defaultRetries); } return next.exchange(request).retry(retries); }; } }
if (HttpMethod.POST.equals(httpMethod)) { headers.setContentType(DEFAULT_CONTENT_TYPE); MultiValueMap<String, String> formParameters = new LinkedMultiValueMap<>();
/** * Returns whether the request is a PATCH request. * * @return */ public boolean isPatchRequest() { return request.getMethod().equals(HttpMethod.PATCH); }
/** * Transform GET-based query parameters (e.g. {@literal &query}) into a list of {@link UberData} objects. */ private List<UberData> determineQueryProperties() { if (!getHttpMethod().equals(HttpMethod.GET)) { return Collections.emptyList(); } if (getHttpMethod().equals(HttpMethod.GET)) { return getQueryMethodParameters().stream() .map(queryParameter -> new UberData() .withName(queryParameter.getName()) .withValue("")) .collect(Collectors.toList()); } else { return Collections.emptyList(); } }
/** * Transform a list of general {@link QueryParameter}s into a list of {@link CollectionJsonData} objects. * * @return */ private List<CollectionJsonData> determineQueryProperties() { if (getHttpMethod().equals(HttpMethod.GET)) { return getQueryMethodParameters().stream() .map(queryProperty -> new CollectionJsonData() .withName(queryProperty.getName()) .withValue("")) .collect(Collectors.toList()); } else { return Collections.emptyList(); } } }
/** * Merges the given incoming object into the given domain object. * * @param domainObject * @param invoker * @param httpMethod * @return */ private ResponseEntity<ResourceSupport> saveAndReturn(Object domainObject, RepositoryInvoker invoker, HttpMethod httpMethod, PersistentEntityResourceAssembler assembler, boolean returnBody) { publisher.publishEvent(new BeforeSaveEvent(domainObject)); Object obj = invoker.invokeSave(domainObject); publisher.publishEvent(new AfterSaveEvent(obj)); PersistentEntityResource resource = assembler.toFullResource(obj); HttpHeaders headers = headersPreparer.prepareHeaders(Optional.of(resource)); if (PUT.equals(httpMethod)) { addLocationHeader(headers, assembler, obj); } if (returnBody) { return ControllerUtils.toResponseEntity(HttpStatus.OK, headers, resource); } else { return ControllerUtils.toEmptyResponse(HttpStatus.NO_CONTENT, headers); } }
.map(model -> { if (model.getHttpMethod().equals(HttpMethod.GET)) {
if (HttpMethod.PATCH.equals(requestMethod)) { throw HttpRequestMethodNotSupportedException.forRejectedMethod(HttpMethod.PATCH)//
@Bean public IntegrationFlow httpReactiveInboundChannelAdapterFlow() { return IntegrationFlows .from(WebFlux.inboundChannelAdapter("/reactivePost") .requestMapping(m -> m.methods(HttpMethod.POST)) .requestPayloadType(ResolvableType.forClassWithGenerics(Flux.class, String.class)) .statusCodeFunction(e -> HttpMethod.POST.equals(e.getMethod()) ? HttpStatus.ACCEPTED : HttpStatus.BAD_REQUEST)) .channel(c -> c.queue("storeChannel")) .get(); }
@Bean public IntegrationFlow httpReactiveInboundGatewayFlowWithErrors() { return IntegrationFlows .from(WebFlux.inboundGateway("/reactivePostErrors") .requestMapping(m -> m.methods(HttpMethod.POST)) .requestPayloadType(ResolvableType.forClassWithGenerics(Flux.class, String.class)) .statusCodeFunction(e -> HttpMethod.POST.equals(e.getMethod()) ? HttpStatus.ACCEPTED : HttpStatus.BAD_REQUEST) .errorChannel(errorFlow().getInputChannel())) .channel(MessageChannels.flux()) .handle((p, h) -> { throw new RuntimeException("errorTest"); }) .get(); }
/** * Returns whether the request is a PATCH request. * * @return */ public boolean isPatchRequest() { return request.getMethod().equals(HttpMethod.PATCH); }
private boolean isParameterTokenSupportedForRequest(ServerHttpRequest request) { return this.allowUriQueryParameter && HttpMethod.GET.equals(request.getMethod()); } }
private static Set<HttpMethod> initAllowedHttpMethods(Set<String> declaredMethods) { Set<HttpMethod> result = new LinkedHashSet<>(declaredMethods.size()); if (declaredMethods.isEmpty()) { for (HttpMethod method : HttpMethod.values()) { if (!HttpMethod.TRACE.equals(method)) { result.add(method); } } } else { boolean hasHead = declaredMethods.contains("HEAD"); for (String method : declaredMethods) { result.add(HttpMethod.valueOf(method)); if (!hasHead && "GET".equals(method)) { result.add(HttpMethod.HEAD); } } } return result; }
private Object findFunctionForPost(ServerWebExchange request, String path) { if (!request.getRequest().getMethod().equals(HttpMethod.POST)) { return null; } path = path.startsWith("/") ? path.substring(1) : path; Consumer<Publisher<?>> consumer = functions.lookup(Consumer.class, path); if (consumer != null) { request.getAttributes().put(WebRequestConstants.CONSUMER, consumer); return consumer; } Function<Object, Object> function = functions.lookup(Function.class, path); if (function != null) { request.getAttributes().put(WebRequestConstants.FUNCTION, function); return function; } return null; }
private Object findFunctionForPost(ServerWebExchange request, String path) { if (!request.getRequest().getMethod().equals(HttpMethod.POST)) { return null; } path = path.startsWith("/") ? path.substring(1) : path; Consumer<Publisher<?>> consumer = functions.lookup(Consumer.class, path); if (consumer != null) { request.getAttributes().put(WebRequestConstants.CONSUMER, consumer); return consumer; } Function<Object, Object> function = functions.lookup(Function.class, path); if (function != null) { request.getAttributes().put(WebRequestConstants.FUNCTION, function); return function; } return null; }
@Override public Mono<MatchResult> matches(ServerWebExchange exchange) { ServerHttpRequest request = exchange.getRequest(); if(this.method != null && !this.method.equals(request.getMethod())) { return MatchResult.notMatch(); } PathContainer path = request.getPath().pathWithinApplication(); boolean match = this.pattern.matches(path); if(!match) { return MatchResult.notMatch(); } Map<String,String> pathVariables = this.pattern.matchAndExtract(path).getUriVariables(); Map<String,Object> variables = new HashMap<>(pathVariables); return MatchResult.match(variables); }
@Override public Mono<MatchResult> matches(ServerWebExchange exchange) { ServerHttpRequest request = exchange.getRequest(); if (this.method != null && !this.method.equals(request.getMethod())) { return MatchResult.notMatch(); } PathContainer path = request.getPath().pathWithinApplication(); boolean match = this.pattern.matches(path); if (!match) { return MatchResult.notMatch(); } Map<String, String> pathVariables = this.pattern.matchAndExtract(path).getUriVariables(); Map<String, Object> variables = new HashMap<>(pathVariables); return MatchResult.match(variables); }