1
1
2
- [ ![ Build Status] ( https://travis-ci.org/WeltN24 /aws-lambda-router.svg?branch=master )] ( https://travis-ci.org/WeltN24 /aws-lambda-router )
2
+ [ ![ Build Status] ( https://travis-ci.org/spring-media /aws-lambda-router.svg?branch=master )] ( https://travis-ci.org/spring-media /aws-lambda-router )
3
3
[ ![ npm version] ( https://badge.fury.io/js/aws-lambda-router.svg )] ( https://badge.fury.io/js/aws-lambda-router )
4
4
[ ![ dependencies] ( https://david-dm.org/WeltN24/aws-lambda-router.svg )] ( https://www.npmjs.com/package/aws-lambda-router )
5
5
@@ -49,27 +49,6 @@ exports.handler = router.handler(
49
49
path: ' /:id' ,
50
50
method: ' DELETE' ,
51
51
action : request => deleteSomething (request .paths .id )
52
- },
53
- {
54
- path: ' /custom-response-object' ,
55
- action: ' GET' ,
56
- action : request => {
57
- return {
58
- // Allow for custom status codes depending on execution.
59
- statusCode: 400 ,
60
- // Headers will merge with CORs headers when enabled.
61
- // Will merge with Content-Type: application/json
62
- headers: {
63
- ' x-fake-header' : ' x-value'
64
- },
65
- // When returning a custom response object, a key of body is required
66
- // The value of body needs to be JSON stringified, this matches
67
- // the expected response for an AWS Lambda.
68
- body: JSON .stringify ({
69
- foo: ' bar'
70
- })
71
- }
72
- }
73
52
}
74
53
],
75
54
debug: true ,
@@ -96,6 +75,30 @@ exports.handler = router.handler(
96
75
});
97
76
```
98
77
78
+ ### Custom response
79
+
80
+ Per default a status code 200 will be returned. This behavior can be override.
81
+
82
+ By providing body in the returned object you can modify statuscode and response headers.
83
+
84
+ ``` js
85
+ return {
86
+ // Allow for custom status codes depending on execution.
87
+ statusCode: 218 ,
88
+ // Headers will merge with CORs headers when enabled.
89
+ // Will merge with Content-Type: application/json
90
+ headers: {
91
+ ' x-new-header' : ' another-value'
92
+ },
93
+ // When returning a custom response object, a key of body is required
94
+ // The value of body needs to be JSON stringified, this matches
95
+ // the expected response for an AWS Lambda.
96
+ body: JSON .stringify ({
97
+ foo: ' bar'
98
+ })
99
+ };
100
+ ```
101
+
99
102
## local developement
100
103
101
104
The best is to work with ``` npm link ```
@@ -105,6 +108,7 @@ See here: http://vansande.org/2015/03/20/npm-link/
105
108
106
109
## Release History
107
110
111
+ * 0.3.0 proxyIntegration: allow for custom status codes from route (thanks to [ @mintuz ] ( https://github.com/mintuz ) )
108
112
* 0.2.2 proxyIntegration: set correct header values now for CORS
109
113
* 0.2.1 proxyIntegration: CORS in Preflight, status code 400 for invalid body, set more CORS headers as default
110
114
* 0.2.0 Attention: breaking changes for configuration; add SNS event process
0 commit comments