@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(); } } } }
if (!req.isExpectMultipart()) { throw new IllegalStateException("Form body not parsed - do you forget to include a BodyHandler?");
if (!req.isExpectMultipart()) { throw new IllegalStateException("Form body not parsed - do you forget to include a BodyHandler?");