[undertow-dev] Force a HttpHandler to accept POST only
Stuart Douglas
sdouglas at redhat.com
Mon Dec 9 05:10:39 EST 2013
What do you want to happen if it is not a post request?
The simplest way is just:
if(!exchange.getRequestMethod().equals(Methods.POST)) {
exchange.setResponseCode(405);
exchange.endExchange();
return;
}
If you want to pick a handler to invoke based on the method you can use:
Handlers.predicate(Predicates.method(Methods.POST), postHandler, nonPostHandler);
Stuart
----- Original Message -----
> From: "Samy Dindane" <samy at dindane.com>
> To: undertow-dev at lists.jboss.org
> Sent: Sunday, 8 December, 2013 6:09:23 PM
> Subject: [undertow-dev] Force a HttpHandler to accept POST only
>
> Hi folks,
>
> I have a HttpHandler that I want to reach with POST requests only .
> I tried exchange.setRequestMethod(new HttpString("POST”)) inside
> handleRequest() , but the HttpHandler still responds to GET requests.
>
> Is there any way to do this?
>
> In case you’d like to check out the code, it can be found here .
> Thank you.
>
> Samy
>
> _______________________________________________
> undertow-dev mailing list
> undertow-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/undertow-dev
More information about the undertow-dev
mailing list