Skip to content

Commit 848f336

Browse files
docs: add custom response headers and template
1 parent ecbc94f commit 848f336

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

README.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ This is the Serverless Framework plugin for AWS Step Functions.
2929
- [Shared Authorizer](#shared-authorizer)
3030
- [LAMBDA_PROXY request template](#lambda_proxy-request-template)
3131
- [Customizing request body mapping templates](#customizing-request-body-mapping-templates)
32+
- [Customizing response headers and templates](#customizing-response-headers-and-templates)
3233
- [Send request to an API](#send-request-to-an-api)
3334
- [Setting API keys for your Rest API](#setting-api-keys-for-your-rest-api)
3435
- [Schedule](#schedule)
@@ -696,6 +697,31 @@ stepFunctions:
696697
definition:
697698
```
698699

700+
#### Customizing response headers and templates
701+
702+
If you'd like to add custom headers in the HTTP response, or customize the default response template (which just returns the response from Step Function's StartExecution API), then you can do so by including your custom headers and [API Gateway response mapping template](https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-mapping-template-reference.html) in `serverless.yml` like so:
703+
704+
```yml
705+
stepFunctions:
706+
stateMachines:
707+
hello:
708+
events:
709+
- http:
710+
path: posts/create
711+
method: POST
712+
response:
713+
headers:
714+
Content-Type: "'application/json'"
715+
X-Application-Id: "'my-app'"
716+
template:
717+
application/json: |
718+
{
719+
"status": 200,
720+
"info": "OK"
721+
}
722+
definition:
723+
```
724+
699725
#### Send request to an API
700726

701727
You can input an value as json in request body, the value is passed as the input value of your statemachine

0 commit comments

Comments
 (0)