Skip to content

Instantly share code, notes, and snippets.

@scottalan
Created June 11, 2019 22:08
Show Gist options
  • Save scottalan/4f179d4f8996575099535728d095d33a to your computer and use it in GitHub Desktop.
Save scottalan/4f179d4f8996575099535728d095d33a to your computer and use it in GitHub Desktop.
Serverless : Examples
# This demonstrates how you can provide a custom template for the Content-Type.
# In this example this would be a POST of Content-Type: application/xml
functions:
parseXml:
handler: handler.parseXml
memorySize: 128
events:
- http:
path: "/angler"
method: post
# https://github.com/serverless/serverless/blob/master/docs/providers/aws/events/apigateway.md#pass-through-behavior
# https://docs.aws.amazon.com/apigateway/latest/developerguide/how-to-method-settings-execution-console.html
integration: lambda
request:
passThrough: NEVER # NEVER, WHEN_NO_MATCH, WHEN_NO_TEMPLATES
# headers:
# Content-Type: "'application/xml'"
template:
application/xml: >
{
"xml": "$input.body"
}
# response:
# headers:
# Content-Type: integration.response.header.Content-Type
cors: true
# This states that we require an api key for this function.
# Clients connecting to this REST Api will need to set the value of
# the API key in the x-api-key header of the request.
private: true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment