4
votes

I've a spring integration http inbound-gateway. I'd like to return specific http status codes in different cases of use. Is there any way to specify the httpStatus in the response???

I tried with a excepion type router where each exception is a specific http status code, but i don't know how to set the status code in the response and I don't find any help about it in the documentation.

Thanks!

1

1 Answers

7
votes

User a <header-enricher/> (or other means) to put the status in the org.springframework.integration.http.HttpHeaders.STATUS_CODE header of the reply message. (The header name is "http_statusCode" but using the constant is generally recommended).

The code can either be an HttpStatus object, or an Integer/String with the status code you want to return.

Please open a 'Documentation' JIRA issue https://jira.springsource.org/browse/INT