Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixes #1631 update request transformer to do some validation logic #1632

Merged
merged 1 commit into from
Feb 28, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@

/**
* Transforms the request body of an active request being processed.
* This is executed by RequestInterceptorExecutionHandler.
* This is executed by RequestInterceptorExecutionHandler. Also, this class will be responsible for
* some special validations that the normal handlers cannot do or not easy to do.
*
* @author Kalev Gonvick
*
Expand Down Expand Up @@ -204,6 +205,17 @@ public void handleRequest(HttpServerExchange exchange) throws Exception {
}
exchange.getRequestHeaders().put(Headers.CONTENT_LENGTH, length);
break;
case "validationError":
// If the rule engine returns any validationError entry, stop the chain and send the res.
// this can be either XML or JSON or TEXT. Just make sure it matches the content type
String errorMessage = (String)result.get("errorMessage");
String contentType = (String)result.get("contentType");
int statusCode = (Integer)result.get("statusCode");
if(logger.isTraceEnabled()) logger.trace("Entry key validationError with errorMessage {} contentType {} statusCode {}");
exchange.getResponseHeaders().add(Headers.CONTENT_TYPE, contentType);
exchange.setStatusCode(statusCode);
exchange.getResponseSender().send(errorMessage);
break;
}
}
}
Expand Down