hanami-api 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +15 -0
- data/hanami-api.gemspec +2 -1
- data/lib/hanami/api.rb +1 -1
- data/lib/hanami/api/block/context.rb +5 -9
- data/lib/hanami/api/version.rb +1 -1
- metadata +21 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 671e8eab5f3b562214858055a272e049368bfce7524d639ffa63cd7003bab804
|
4
|
+
data.tar.gz: 461f4066a630f1a1bd66dbd52f4a977a79a4e09737f5861aeabfcc89d87aee04
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e5398ddac6f97af3898faefd795bbb37f6be9d334163e90e0b68b004eab11e4923b366cc6b44504d06e16b7b67c2b3a3e46ca8a106ee694e65f2f83ab2ab1f41
|
7
|
+
data.tar.gz: 34ad6218b1001a4b66a4ec9512f320649843928afc98bcd968a347dae0d23df2989ebc46bbd407f93734f934cbd725ded04e8528e9f04e365c180d8748a73097
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,10 @@
|
|
1
1
|
# Hanami::API
|
2
2
|
Minimal, extremely fast, lightweight Ruby framework for HTTP APIs.
|
3
3
|
|
4
|
+
## v0.1.2 - 2020-10-21
|
5
|
+
### Fixed
|
6
|
+
- [Luca Guidi] Ensure to be able to instantiate an `Hanami::API` app multiple times
|
7
|
+
|
4
8
|
## v0.1.1 - 2020-05-20
|
5
9
|
### Fixed
|
6
10
|
- [Luca Guidi] Ensure Rack middleware to be mounted in scopes without a leading slash
|
data/README.md
CHANGED
@@ -28,6 +28,7 @@ Minimal, extremely fast, lightweight Ruby framework for HTTP APIs.
|
|
28
28
|
- [json](#json)
|
29
29
|
+ [Scope](#scope)
|
30
30
|
+ [Rack Middleware](#rack-middleware)
|
31
|
+
+ [Body Parsers](#body-parsers)
|
31
32
|
* [Development](#development)
|
32
33
|
* [Contributing](#contributing)
|
33
34
|
|
@@ -410,6 +411,20 @@ it's part of the top level scope. `ApiAuthentication` it's used for all the API
|
|
410
411
|
versions, because it's defined in the `"api"` scope. `ApiV1Deprecation` is used
|
411
412
|
only by the routes in `"v1"` scope, but not by `"v2"`.
|
412
413
|
|
414
|
+
### Body Parsers
|
415
|
+
|
416
|
+
Rack ignores request bodies unless they come from a form submission.
|
417
|
+
If you have an endpoint that accepts JSON, the request payload isn’t available in `params`.
|
418
|
+
|
419
|
+
In order to parse JSON payload and make it avaliable in `params`, you should add the following lines to `config.ru`:
|
420
|
+
|
421
|
+
```ruby
|
422
|
+
# frozen_string_literal: true
|
423
|
+
require "hanami/middleware/body_parser"
|
424
|
+
|
425
|
+
use Hanami::Middleware::BodyParser, :json
|
426
|
+
```
|
427
|
+
|
413
428
|
## Development
|
414
429
|
|
415
430
|
After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
data/hanami-api.gemspec
CHANGED
@@ -33,5 +33,6 @@ Gem::Specification.new do |spec|
|
|
33
33
|
|
34
34
|
spec.add_development_dependency "rake", "~> 13.0"
|
35
35
|
spec.add_development_dependency "rspec", "~> 3.8"
|
36
|
-
spec.add_development_dependency "rubocop", "~> 0.
|
36
|
+
spec.add_development_dependency "rubocop", "~> 0.86"
|
37
|
+
spec.add_development_dependency "yard", "~> 0.9"
|
37
38
|
end
|
data/lib/hanami/api.rb
CHANGED
@@ -130,8 +130,6 @@ module Hanami
|
|
130
130
|
# @since 0.1.0
|
131
131
|
# @api private
|
132
132
|
#
|
133
|
-
# rubocop:disable Metrics/AbcSize
|
134
|
-
# rubocop:disable Metrics/MethodLength
|
135
133
|
def call
|
136
134
|
case caught
|
137
135
|
in String => body
|
@@ -147,15 +145,13 @@ module Hanami
|
|
147
145
|
# which results in a bug.
|
148
146
|
[status, headers, [self.body || http_status(status)]]
|
149
147
|
# rubocop:enable Style/RedundantSelf
|
150
|
-
in [Integer, String
|
151
|
-
[
|
152
|
-
in [Integer, Hash, String
|
153
|
-
headers.merge!(
|
154
|
-
[
|
148
|
+
in [Integer => status, String => body]
|
149
|
+
[status, headers, [body]]
|
150
|
+
in [Integer => status, Hash => caught_headers, String => body]
|
151
|
+
headers.merge!(caught_headers)
|
152
|
+
[status, headers, [body]]
|
155
153
|
end
|
156
154
|
end
|
157
|
-
# rubocop:enable Metrics/MethodLength
|
158
|
-
# rubocop:enable Metrics/AbcSize
|
159
155
|
|
160
156
|
private
|
161
157
|
|
data/lib/hanami/api/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hanami-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Luca Guidi
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-10-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: hanami-router
|
@@ -58,14 +58,28 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '0.
|
61
|
+
version: '0.86'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '0.
|
68
|
+
version: '0.86'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: yard
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0.9'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0.9'
|
69
83
|
description: Extremely fast and lightweight HTTP API
|
70
84
|
email:
|
71
85
|
- me@lucaguidi.com
|
@@ -100,7 +114,7 @@ metadata:
|
|
100
114
|
homepage_uri: http://rubygems.org
|
101
115
|
source_code_uri: https://github.com/hanami/api
|
102
116
|
changelog_uri: https://github.com/hanami/api/blob/master/CHANGELOG.md
|
103
|
-
post_install_message:
|
117
|
+
post_install_message:
|
104
118
|
rdoc_options: []
|
105
119
|
require_paths:
|
106
120
|
- lib
|
@@ -116,7 +130,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
116
130
|
version: '0'
|
117
131
|
requirements: []
|
118
132
|
rubygems_version: 3.1.3
|
119
|
-
signing_key:
|
133
|
+
signing_key:
|
120
134
|
specification_version: 4
|
121
135
|
summary: Hanami API
|
122
136
|
test_files: []
|