Skip to content

Commit 1256ab4

Browse files
Update Readme
1 parent 11c0c98 commit 1256ab4

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
@@ -186,6 +186,32 @@ stepFunctions:
186186

187187
Configuring the cors property sets Access-Control-Allow-Origin, Access-Control-Allow-Headers, Access-Control-Allow-Methods,Access-Control-Allow-Credentials headers in the CORS preflight response.
188188

189+
#### Customizing request body mapping templates
190+
191+
The plugin generates default body mapping templates for `application/json` and `application/x-www-form-urlencoded` content types. If you'd like to add more content types or customize the default ones, you can do so by including them in `serverless.yml`:
192+
193+
```yml
194+
stepFunctions:
195+
stateMachines:
196+
hello:
197+
events:
198+
- http:
199+
path: posts/create
200+
method: POST
201+
request:
202+
template:
203+
application/json: |
204+
#set( $body = $util.escapeJavaScript($input.json('$')) )
205+
#set( $name = $util.escapeJavaScript($input.json('$.data.attributes.order_id')) )
206+
{
207+
"input": "$body",
208+
"name": "$name",
209+
"stateMachineArn":"arn:aws:states:#{AWS::Region}:#{AWS::AccountId}:stateMachine:processOrderFlow-${opt:stage}"
210+
}
211+
name: processOrderFlow-${opt:stage}
212+
definition:
213+
```
214+
189215
#### Send request to an API
190216
You can input an value as json in request body, the value is passed as the input value of your statemachine
191217

0 commit comments

Comments
 (0)