modern 0.4.2 → 0.4.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2758b166b5113cad1819574884d04dafe166f70033e87cfcf54fc0615a33b7f6
4
- data.tar.gz: df1d24226b92fbfb1ec37a06e802390857a5a86d0cfc2ab56ac20dc669d49dc6
3
+ metadata.gz: f483d74d2aa71c07344b8ab689d473b52255fe52e93c45116f8f898887989f70
4
+ data.tar.gz: 81a87980bb858c2839c779f98364f699c4126a908cd4a6b732812dd749956262
5
5
  SHA512:
6
- metadata.gz: b3fdfd253b7f161a2f850a4a71dcd4effa39d0561b0ebbd1d2203a2fa7801c250d333fc4f9e69d7072f2dfa41d9937a112b97052f08bd030ec64a122dd4a0458
7
- data.tar.gz: 23291ac933a23779d4d5b762020f1fc67a42e5585b05593801f760aee8b2ed6cd7f850b3a21bd6d26f8ed0080dfbdbf7db7fef0ea94ed197c169cf9497543fc9
6
+ metadata.gz: b168abd8e525ab5f8ab193debbc99b94b61b42eb7dab708825d89be5cb0a804c6b15697036db70619c360cf779c1a95847a956e843adad4ca67bf4c71507b958
7
+ data.tar.gz: 0a0407e5e6c50609c8ecf7ae2d791c33a76fe1a0eebeb28ad0515e196a32ab235db4cb70f701f845d9f1b22c478a7443b24f497e3eb2dbbeb446d295c6cf50e2
@@ -32,7 +32,7 @@ module Modern
32
32
 
33
33
  params = parse_parameters(request, route)
34
34
  body = parse_request_body(request, route) unless route.request_body.nil?
35
- raise Errors::BadRequestError \
35
+ raise Errors::BadRequestError, "Request body is required." \
36
36
  if body.nil? && route.request_body&.required
37
37
 
38
38
  begin
@@ -20,8 +20,13 @@ module Modern
20
20
  end
21
21
 
22
22
  def parse_request_body(request, route)
23
- input_converter = determine_input_converter(request, route)
24
- raise Modern::Errors::UnsupportedMediaTypeError if input_converter.nil?
23
+ # RFC 2616; you MAY sniff content but SHOULD return application/octet-stream
24
+ # if the input Content-Type remains unknown. However, it seems like Rack may
25
+ # default to application/x-www-form-urlencoded; Rack::Test definitely does.
26
+ content_type = (request.content_type || "application/octet-stream").downcase.strip
27
+
28
+ input_converter = determine_input_converter_for_type(content_type, route)
29
+ raise Modern::Errors::UnsupportedMediaTypeError, content_type if input_converter.nil?
25
30
 
26
31
  raw = input_converter.converter.call(request.body)
27
32
 
@@ -52,11 +57,7 @@ module Modern
52
57
  end
53
58
  end
54
59
 
55
- def determine_input_converter(request, route)
56
- # RFC 2616; you MAY sniff content but SHOULD return application/octet-stream
57
- # if the input Content-Type remains unknown. However, it seems like Rack may
58
- # default to application/x-www-form-urlencoded; Rack::Test definitely does.
59
- content_type = (request.content_type || "application/octet-stream").downcase.strip
60
+ def determine_input_converter_for_type(content_type, route)
60
61
  route.input_converters_by_type[content_type]
61
62
  end
62
63
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Modern
4
- VERSION = "0.4.2"
4
+ VERSION = "0.4.3"
5
5
  OPENAPI_VERSION = "3.0.1"
6
6
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: modern
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.2
4
+ version: 0.4.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ed Ropple
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-03-01 00:00:00.000000000 Z
11
+ date: 2018-03-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler