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

Bad request handler. #3553

Merged
merged 4 commits into from
Oct 15, 2021

Conversation

tomas-langer
Copy link
Member

@tomas-langer tomas-langer commented Oct 14, 2021

Resolves #1893

Signed-off-by: Tomas Langer tomas.langer@oracle.com

To customize bad request handling:

 webServer = WebServer.builder()
                .directHandler(MyClass::directHandler, EventType.BAD_REQUEST)
                .routing(routing())
                .build();

and the handler:

private static TransportResponse badRequestHandler(DirectHandler.TransportRequest request,
                                                       DirectHandler.EventType eventType,
                                                       Http.ResponseStatus defaultStatus,
                                                       String message) {
              return TransportResponse.builder()
                    .status(Http.Status.TEMPORARY_REDIRECT_307)
                    .header(Http.Header.LOCATION, "/errorPage")
                    .build();
}

Signed-off-by: Tomas Langer <tomas.langer@oracle.com>
@tomas-langer tomas-langer self-assigned this Oct 14, 2021
Signed-off-by: Tomas Langer <tomas.langer@oracle.com>
@tomas-langer tomas-langer added this to the 2.4.0 milestone Oct 14, 2021
Signed-off-by: Tomas Langer <tomas.langer@oracle.com>
Signed-off-by: Tomas Langer <tomas.langer@oracle.com>
@tomas-langer tomas-langer merged commit 33e3d45 into helidon-io:master Oct 15, 2021
@tomas-langer tomas-langer deleted the 1893-bad-request-handler branch October 15, 2021 19:54
dalexandrov pushed a commit to dalexandrov/helidon that referenced this pull request Oct 21, 2021
* Direct handlers for requests bypassing routing

Signed-off-by: Tomas Langer <tomas.langer@oracle.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

When request URL is invalid, response should be configurable (redirect to different URL)
2 participants