HTTP Inbound adapter Differentiate between supported-methods
I have a http inbound adapter defined like so -
<int-http:inbound-channel-adapter id="httpInboundAdapter" channel="receiveChannel" name="/inboundAdapter.htm" supported-methods="GET, POST" /> <int:channel id="receiveChannel"/> <int:service-activator input-channel="receiveChannel" expression="@sayHello.sayHello(payload)" />
I would like to be able to differentiate between a GET and POST request and respond differently to them. How I can do that ..?
The message on receiveChannel will have a header http_requestMethod set to 'GET' or 'POST'.
You can use expression="@sayHello.sayHello(payload, headers['http_requestMethod'])", where the second parameter is a String.
To avoid hard-coding the literal, you can use headers[T(org.springframework.integration.http.HttpHeaders).REQUEST_METHOD].
FYI REQUEST_URL and USER_PRINCIPAL are also populated; and, on the adapter/gateway, you also populate other headers with http request parameters or URI variables.