<apikit:config name="api-config"
api="api.raml"
outboundHeadersMapName="outboundHeaders"
httpStatusVarName="httpStatus"/>
Configuring the Response Headers and Status Code
Map APIkit for REST outbound headers and HTTP status values to variables the HTTP Listener writes into each response. Configure outboundHeadersMapName and httpStatusVarName on apikit:config so flows set vars.outboundHeaders and vars.httpStatus consistently across success and error paths. The steps align listener response blocks with those variable names.
Configure Variable Names
You can configure the default variables that the HTTP listener searches for by configuring these properties in APIkit Router:
-
outboundHeadersMapNameName of the variable that contains a headers map added in the response (
outboundHeadersby default) -
httpStatusVarNameName of the variable that stores the status code to set in the response (
httpStatusby default)
APIkit Router creates both variables and facilitates including custom HTTP headers and status codes in the response.
To modify the default names of these variables, update the default HTTP listener configuration to align the variable names and the configuration.
<http:listener config-ref="api-httpListenerConfig" path="/api/*">
<http:response
statusCode="#[vars.httpStatus default 200]">
<http:headers>#[vars.outboundHeaders default {}]</http:headers>
</http:response>
<http:error-response
statusCode="#[vars.httpStatus default 500]">
<http:body>#[payload]</http:body>
<http:headers>#[vars.outboundHeaders default {}]</http:headers>
</http:error-response>
</http:listener>
Add a Header to a Response
Put the header to add in the outboundHeaders map, as shown in the following example:
<set-variable
value='#[vars.outboundHeaders default {} ++ {newHeaderName: "Header value"}]'
variableName="outboundHeaders"/>



