hanami-api 0.1.1 → 0.1.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 33a0b691f992906407c5d0c6bdf4c844d6b7ff4deb420b88f1e73c45768f210f
4
- data.tar.gz: 01a7c8f0972e5ea9a1eff88c81d5966a9c22192c99ca9e3416cfdba9c9fdbc38
3
+ metadata.gz: 671e8eab5f3b562214858055a272e049368bfce7524d639ffa63cd7003bab804
4
+ data.tar.gz: 461f4066a630f1a1bd66dbd52f4a977a79a4e09737f5861aeabfcc89d87aee04
5
5
  SHA512:
6
- metadata.gz: a40490671a64ebdf57939a470de03045f29224859453465aa5ed60d39c19d2d8f2d342f8cd7116a90ae6e754b761b609f0cabc6d1ed7daac3df991ac0c25b2ce
7
- data.tar.gz: f8791ad3eaa0be2b0e114f124d5e193b5a112ea3a4282c01ebc21a5c860c37e367484ade01f44392962853c6126511f30f9fc32829ebb078e2a86b1a47583358
6
+ metadata.gz: e5398ddac6f97af3898faefd795bbb37f6be9d334163e90e0b68b004eab11e4923b366cc6b44504d06e16b7b67c2b3a3e46ca8a106ee694e65f2f83ab2ab1f41
7
+ data.tar.gz: 34ad6218b1001a4b66a4ec9512f320649843928afc98bcd968a347dae0d23df2989ebc46bbd407f93734f934cbd725ded04e8528e9f04e365c180d8748a73097
@@ -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.
@@ -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.79"
36
+ spec.add_development_dependency "rubocop", "~> 0.86"
37
+ spec.add_development_dependency "yard", "~> 0.9"
37
38
  end
@@ -293,7 +293,7 @@ module Hanami
293
293
  end
294
294
 
295
295
  # @since 0.1.0
296
- def initialize(router: self.class.router)
296
+ def initialize(router: self.class.router.dup)
297
297
  @router = router
298
298
 
299
299
  freeze
@@ -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] => response
151
- [response[0], headers, [response[1]]]
152
- in [Integer, Hash, String] => response
153
- headers.merge!(response[1])
154
- [response[0], headers, [response[2]]]
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
 
@@ -3,6 +3,6 @@
3
3
  module Hanami
4
4
  class API
5
5
  # @since 0.1.0
6
- VERSION = "0.1.1"
6
+ VERSION = "0.1.2"
7
7
  end
8
8
  end
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.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-05-20 00:00:00.000000000 Z
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.79'
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.79'
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: []