|
4 | 4 | [](https://coveralls.io/github/aceew/lambda-proxy-router?branch=master)
|
5 | 5 | [](https://travis-ci.org/aceew/lambda-proxy-router)
|
6 | 6 |
|
7 |
| -The purpose of this package is to easily organize the mapping between your code and your API request within Lambda functions that have more than one single purpose. This takes away the need for the configuration of mapping templates and handles the standard event Amazon send through with Lambda functions with proxy configuration. The desired effect of the package is to make it easier to build microservices that have multiple API Gateway endpoints. |
| 7 | +The purpose of this package is to easily organize the mapping between your code and your API request within Lambda functions that have more than one purpose. This takes away the need for the configuration of mapping templates and handles the standard event object that Amazon sends through with Lambda functions with proxy configuration. The desired effect of the package is to make it easier to build microservices that have multiple API Gateway endpoints. |
8 | 8 |
|
9 | 9 | ## Contents
|
10 | 10 | - [Usage](#usage)
|
@@ -110,9 +110,27 @@ Here's all the keys that are currently available in the request object:
|
110 | 110 |
|
111 | 111 |
|
112 | 112 | ## Response
|
113 |
| -The response parameter is used to send a response back to API gateway. This method requires a parameter object to specify the body, headers and http status code. If none of these are specified, default values of empty headers, statusCode 200, and a stringified value of whatever was sent in the parameter. |
| 113 | +The response parameter is used to send a response back to API gateway. This method requires a parameter object to specify the body, headers and http status code. |
114 | 114 |
|
115 |
| -So `response("hello world")` would work out as: |
| 115 | +| Key | Type | Value | Default |
| 116 | +|---|---|--- |
| 117 | +| params | Object | Parameters object | {} | |
| 118 | +| params.statusCode | integer | The HTTP status code | 200 |
| 119 | +| params.headers | Object | Any headers to be returned in the response. | {} |
| 120 | +| params.body | mixed | Your response body, whatever is specified will be `JSON.stringify`'d. If body is not set the body will be defined as the params object. | `JSON.stringify(params)` |
| 121 | + |
| 122 | +Here is the recommended way to call the response method. |
| 123 | +``` |
| 124 | +response({ |
| 125 | + statusCode: 200, |
| 126 | + headers: { "x-your-header": "header value" }, |
| 127 | + body: { "response-object-key": "data" }, |
| 128 | +}); |
| 129 | +``` |
| 130 | + |
| 131 | +If any of the correct parameters are not specified, default values of empty headers, statusCode 200, and a stringified value of whatever was sent in the parameter for the body are used to make the response valid. |
| 132 | + |
| 133 | +So `response('hello world')` would work out as: |
116 | 134 | ```
|
117 | 135 | {
|
118 | 136 | statusCode: 200,
|
|
0 commit comments