INT-3447: HTTP-inbound: status-code-expression

JIRA: https://jira.spring.io/browse/INT-3447

Polishing
This commit is contained in:
Artem Bilan
2014-07-04 13:22:16 +03:00
committed by Gary Russell
parent c309b031f8
commit 93be035cae
10 changed files with 139 additions and 16 deletions

View File

@@ -317,6 +317,29 @@ By default the HTTP request will be generated using an instance of <classname>Si
</listitem>
</itemizedlist>
<para><emphasis>Response StatusCode</emphasis></para>
<para>
Starting with <emphasis>version 4.1</emphasis> the <code>&lt;http:inbound-channel-adapter&gt;</code>
can be configured with a <code>status-code-expression</code> to override the default <code>200 OK</code> status.
The expression must return an object which can be converted to a
<classname>org.springframework.http.HttpStatus</classname> enum value.
The <code>evaluationContext</code> has a <classname>BeanResolver</classname> but no variables,
so the usage of this attribute is somewhat limited.
An example might be to resolve, at runtime, some scoped Bean that returns a status code value but,
most likely, it will be set to a fixed value
such as <code>status-code=expression="'204'"</code> (No Content), or
<code>status-code-expression="T(org.springframework.http.HttpStatus).NO_CONTENT"</code>.
By default, <code>status-code-expression</code> is null meaning that the normal '200 OK' response status
will be returned.
<programlisting language="xml"><![CDATA[<http:inbound-channel-adapter id="inboundController"
channel="requests" view-name="foo" error-code="oops"
status-code-expression="T(org.springframework.http.HttpStatus).ACCEPTED">
<request-mapping headers="BAR"/>
</http:inbound-channel-adapter>]]></programlisting>
The <code>&lt;http:inbound-gateway&gt;</code> resolves the 'status code' from the <code>http_statusCode</code>
header of the reply Message.
</para>
<para><emphasis>URI Template Variables and Expressions</emphasis></para>
<para>
By Using the <emphasis>path</emphasis> attribute in conjunction with the

View File

@@ -46,5 +46,13 @@
before sending the request.
</para>
</section>
<section id="4.1-http-status-code">
<title>Http Inbound Channel Adapter and StatusCode</title>
<para>
The <code>&lt;http:inbound-channel-adapter&gt;</code> can now be configured with a
<code>status-code-expression</code> to override the default <code>200 OK</code> status.
See <xref linkend="http-namespace"/> for more information.
</para>
</section>
</section>
</chapter>