private RoutingContext mockContext(String requestPath, HttpMethod method) { RoutingContext context = Mockito.mock(RoutingContext.class); HttpServerRequest httpRequest = Mockito.mock(HttpServerRequest.class); Mockito.when(context.request()).thenReturn(httpRequest); Mockito.when(httpRequest.path()).thenReturn(requestPath); Mockito.when(httpRequest.method()).thenReturn(method); return context; } }
@Override public void handle(RoutingContext context) { HttpServerRequest req = context.request(); if (req.method() != HttpMethod.POST) { context.fail(405); // Must be a POST } else { if (!req.isExpectMultipart()) { throw new IllegalStateException("Form body not parsed - do you forget to include a BodyHandler?"); } // check required parameters MultiMap params = req.formAttributes(); Optional<String> missingParameter = requiredParams.stream().filter(param -> { String paramValue = params.get(param); if (paramValue == null) { logger.warn("No {} provided in form - did you forget to include a BodyHandler?", param); return true; } return false; }).findFirst(); if (missingParameter.isPresent()) { redirectToPage(context, Collections.singletonMap(ERROR_PARAM, "missing_required_parameters")); } else { context.next(); } } } }
@Override public void handle(RoutingContext context) { HttpServerRequest req = context.request(); if (req.method() != HttpMethod.POST) { context.fail(405); // Must be a POST } else { if (!req.isExpectMultipart()) { throw new IllegalStateException("Form body not parsed - do you forget to include a BodyHandler?"); } // check required parameters MultiMap params = req.formAttributes(); Optional<String> missingParameter = requiredParams.stream().filter(param -> { String paramValue = params.get(param); if (paramValue == null) { logger.warn("No {} provided in form - did you forget to include a BodyHandler?", param); return true; } return false; }).findFirst(); if (missingParameter.isPresent()) { redirectToPage(context, Collections.singletonMap(ERROR_PARAM, "missing_required_parameters")); } else { context.next(); } } } }
public ClientRequest(HttpServerRequest serverRequest) { this.path = serverRequest.path(); this.method = serverRequest.method(); this.headers = MultiMap.caseInsensitiveMultiMap().setAll(serverRequest.headers()); this.params = UriHelper.getParams(serverRequest.uri()); this.formAttributes = MultiMap.caseInsensitiveMultiMap().setAll(serverRequest.formAttributes()); }
@Override public void handle(RoutingContext context) { final String path = context.request().path(); final HttpMethod method = context.request().method(); if (isPathSupportedByFlow(path, defaultFlow)) { if (isMethodAllowedInFlow(method, defaultFlow)) { context.next(); } else { LOGGER.warn("{} path supported by DefaultFlow. {} method not allowed.", path, method); context.fail(HttpResponseStatus.METHOD_NOT_ALLOWED.code()); } } else if (isPathSupportedByFlow(path, customFlow)) { if (isMethodAllowedInFlow(method, customFlow)) { context.next(); } else { LOGGER.warn("{} path supported by CustomFlow. {} method not allowed.", path, method); context.fail(HttpResponseStatus.METHOD_NOT_ALLOWED.code()); } } else { LOGGER.warn("{} {} is not supported by default and custom flows.", method, path); context.fail(HttpResponseStatus.NOT_FOUND.code()); } }
@Override public void handle(RoutingContext context) { final String path = context.request().path(); final HttpMethod method = context.request().method(); if (isPathSupportedByFlow(path, defaultFlow)) { if (isMethodAllowedInFlow(method, defaultFlow)) { context.next(); } else { LOGGER.warn("{} path supported by DefaultFlow. {} method not allowed.", path, method); context.fail(HttpResponseStatus.METHOD_NOT_ALLOWED.code()); } } else if (isPathSupportedByFlow(path, customFlow)) { if (isMethodAllowedInFlow(method, customFlow)) { context.next(); } else { LOGGER.warn("{} path supported by CustomFlow. {} method not allowed.", path, method); context.fail(HttpResponseStatus.METHOD_NOT_ALLOWED.code()); } } else { LOGGER.warn("{} {} is not supported by default and custom flows.", method, path); context.fail(HttpResponseStatus.NOT_FOUND.code()); } }
@Override public void handle(RoutingContext context) { final String path = context.request().path(); final HttpMethod method = context.request().method(); if (isPathSupportedByFlow(path, defaultFlow)) { if (isMethodAllowedInFlow(method, defaultFlow)) { context.next(); } else { LOGGER.warn("{} path supported by DefaultFlow. {} method not allowed.", path, method); context.fail(HttpResponseStatus.METHOD_NOT_ALLOWED.code()); } } else if (isPathSupportedByFlow(path, customFlow)) { if (isMethodAllowedInFlow(method, customFlow)) { context.next(); } else { LOGGER.warn("{} path supported by CustomFlow. {} method not allowed.", path, method); context.fail(HttpResponseStatus.METHOD_NOT_ALLOWED.code()); } } else { LOGGER.warn("{} {} is not supported by default and custom flows.", method, path); context.fail(HttpResponseStatus.NOT_FOUND.code()); } }
public ClientRequest(HttpServerRequest serverRequest) { this.path = serverRequest.path(); this.method = serverRequest.method(); this.headers = MultiMap.caseInsensitiveMultiMap().setAll(serverRequest.headers()); this.params = UriHelper.getParams(serverRequest.uri()); this.formAttributes = MultiMap.caseInsensitiveMultiMap().setAll(serverRequest.formAttributes()); }
ResteasyHttpHeaders headers = VertxUtil.extractHttpHeaders(request.getDelegate()); HttpServerResponse response = request.response(); VertxHttpResponse vertxResponse = new VertxHttpResponseWithWorkaround(response.getDelegate(), dispatcher.getProviderFactory(), request.method()); VertxHttpRequest vertxRequest = new VertxHttpRequest(ctx.getDelegate(), headers, uriInfo, request.rawMethod(), dispatcher.getDispatcher(), vertxResponse, false); if (buff.length() > 0)
ResteasyHttpHeaders headers = VertxUtil.extractHttpHeaders(request.getDelegate()); HttpServerResponse response = request.response(); VertxHttpResponse vertxResponse = new VertxHttpResponseWithWorkaround(response.getDelegate(), dispatcher.getProviderFactory(), request.method()); VertxHttpRequest vertxRequest = new VertxHttpRequest(ctx.getDelegate(), headers, uriInfo, request.rawMethod(), dispatcher.getDispatcher(), vertxResponse, false); if (buff.length() > 0)