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(a)dindane.com>
To: undertow-dev(a)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(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/undertow-dev