yake 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +15 -21
- data/lib/yake/api.rb +1 -0
- data/lib/yake/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 117ea613cf7d5a703aba3702eb6ab076fa77490c7e7a901b1e00c22db5c55675
|
4
|
+
data.tar.gz: 8a9a8efba6b480218c2adf79990f567ed2d5a01756e98f4aa4e1d2ee7a6734fa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9c543d7f07274ba4b6fb707fcd2326dfc33a10e027723d39a78eaf0bf5937209968759b1caa497d1a024911d70d76221da449346da67defd8d0c2ee1a9a8dfad
|
7
|
+
data.tar.gz: 64f6319d4ad3578aa7920caba1315995b05df6790862bf0256a4b5019cf3e64c64b7861b4eec25acf4a4e729bfb44bc0e68b06863bcf7918a0980c2921a52fc5
|
data/README.md
CHANGED
@@ -1,5 +1,10 @@
|
|
1
1
|
# λake
|
2
2
|
|
3
|
+

|
4
|
+
[](https://github.com/amancevice/yake/actions)
|
5
|
+
[](https://codeclimate.com/github/amancevice/yake/test_coverage)
|
6
|
+
[](https://codeclimate.com/github/amancevice/yake/maintainability)
|
7
|
+
|
3
8
|
Write your AWS Lambda function handlers using a Rake-like declarative syntax:
|
4
9
|
|
5
10
|
```ruby
|
@@ -94,41 +99,33 @@ Requiring the `yake/api` module will add the API-specific DSL into your handler.
|
|
94
99
|
Define API routes using Sinatra-like syntax
|
95
100
|
|
96
101
|
```ruby
|
97
|
-
# Declare 'DELETE /…' route key
|
98
102
|
delete "/…" do |event|
|
99
|
-
#
|
103
|
+
# Handle 'DELETE /…' route key events
|
100
104
|
end
|
101
105
|
|
102
|
-
# Declare 'GET /…' route key
|
103
106
|
get "/…" do |event|
|
104
|
-
#
|
107
|
+
# Handle 'GET /…' route key events
|
105
108
|
end
|
106
109
|
|
107
|
-
# Declare 'HEAD /…' route key
|
108
110
|
head "/…" do |event|
|
109
|
-
#
|
111
|
+
# Handle 'HEAD /…' route key events
|
110
112
|
end
|
111
113
|
|
112
|
-
# Declare 'OPTIONS /…' route key
|
113
114
|
options "/…" do |event|
|
114
|
-
#
|
115
|
+
# Handle 'OPTIONS /…' route key events
|
115
116
|
end
|
116
117
|
|
117
|
-
# Declare 'PATCH /…' route key
|
118
118
|
patch "/…" do |event|
|
119
|
-
#
|
119
|
+
# Handle 'PATCH /…' route key events
|
120
120
|
end
|
121
121
|
|
122
|
-
# Declare 'POST /…' route key
|
123
122
|
post "/…" do |event|
|
124
|
-
#
|
123
|
+
# Handle 'POST /…' route key events
|
125
124
|
end
|
126
125
|
|
127
|
-
# Declare 'PUT /…' route key
|
128
126
|
put "/…" do |event|
|
129
|
-
#
|
127
|
+
# Handle 'PUT /…' route key events
|
130
128
|
end
|
131
|
-
|
132
129
|
```
|
133
130
|
|
134
131
|
Helper methods are also made available to help produce a response for API Gateway:
|
@@ -137,12 +134,13 @@ Set a default header for ALL responses:
|
|
137
134
|
|
138
135
|
```ruby
|
139
136
|
header "content-type" => "application/json; charset=utf-8"
|
137
|
+
header "x-custom-header" => "fizz"
|
140
138
|
```
|
141
139
|
|
142
140
|
Produce an API Gateway-style response object:
|
143
141
|
|
144
142
|
```ruby
|
145
|
-
respond 200, { ok: true }.to_json, "x-extra-header" => "
|
143
|
+
respond 200, { ok: true }.to_json, "x-extra-header" => "buzz"
|
146
144
|
# {
|
147
145
|
# "statusCode" => 200,
|
148
146
|
# "body" => '{"ok":true}',
|
@@ -153,7 +151,7 @@ respond 200, { ok: true }.to_json, "x-extra-header" => "fizz"
|
|
153
151
|
Route an event to one of the declared routes:
|
154
152
|
|
155
153
|
```ruby
|
156
|
-
|
154
|
+
handler :lambda_handler do |event|
|
157
155
|
route event
|
158
156
|
rescue Yake::UndeclaredRoute => err
|
159
157
|
respond 404, { message: err.message }.to_json
|
@@ -175,7 +173,3 @@ Bug reports and pull requests are welcome on GitHub at https://github.com/amance
|
|
175
173
|
## License
|
176
174
|
|
177
175
|
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
178
|
-
|
179
|
-
```
|
180
|
-
|
181
|
-
```
|
data/lib/yake/api.rb
CHANGED
data/lib/yake/version.rb
CHANGED