apia 3.7.1 → 3.8.0
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/lib/apia/dsls/endpoint.rb +1 -1
- data/lib/apia/endpoint.rb +7 -3
- data/lib/apia/request.rb +4 -2
- data/lib/apia/version.rb +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c3045cadda1c5b6cdbfd059d7ac5e6ad90f890f73b72ba7b9807370b4034ffc1
|
4
|
+
data.tar.gz: 4d542e092f2b7bc81ed416c31b320a04546e4fa8d7151cdb89a2b616dfd7e004
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fef0a20ce38cab8ed6a341004285188d8a06b1bc90612f5c96b622a11c734bb84fcd276fceff8424c178fed1b9d1f8d0c518f7a0ca29d988f8984b647a684edc
|
7
|
+
data.tar.gz: 5f6f244da3f572641b203a9f4bb3d0728472694c7eeb67b58fd668d97727b1f8300aacb6a63e7446864abcea18759e43a7df4aa9a5e42211039def1dd7bd3a8c
|
data/lib/apia/dsls/endpoint.rb
CHANGED
data/lib/apia/endpoint.rb
CHANGED
@@ -47,7 +47,7 @@ module Apia
|
|
47
47
|
response = Response.new(request, self)
|
48
48
|
environment = RequestEnvironment.new(request, response)
|
49
49
|
|
50
|
-
catch_errors(response) do
|
50
|
+
catch_errors(response, environment) do
|
51
51
|
# Determine an authenticator for this endpoint
|
52
52
|
request.authenticator = definition.authenticator || request.controller&.definition&.authenticator || request.api&.definition&.authenticator
|
53
53
|
|
@@ -92,10 +92,14 @@ module Apia
|
|
92
92
|
#
|
93
93
|
# @param response [Apia::Response]
|
94
94
|
# @return [void]
|
95
|
-
def catch_errors(response)
|
95
|
+
def catch_errors(response, environment)
|
96
96
|
yield
|
97
97
|
rescue Apia::RuntimeError => e
|
98
|
-
|
98
|
+
# If the error was triggered by the authenticator, the cors headers wont yet have been merged
|
99
|
+
# so ensure cors headers are merged here
|
100
|
+
response.headers.merge!(environment.cors.to_headers)
|
101
|
+
|
102
|
+
catch_errors(response, environment) do
|
99
103
|
response.body = { error: e.hash }
|
100
104
|
response.status = e.http_status
|
101
105
|
response.headers['x-api-schema'] = 'json-error'
|
data/lib/apia/request.rb
CHANGED
@@ -36,7 +36,7 @@ module Apia
|
|
36
36
|
end
|
37
37
|
|
38
38
|
def body?
|
39
|
-
has_header?(
|
39
|
+
has_header?(::Rack::RACK_INPUT)
|
40
40
|
end
|
41
41
|
|
42
42
|
def params
|
@@ -58,7 +58,9 @@ module Apia
|
|
58
58
|
end
|
59
59
|
|
60
60
|
def get_json_body_from_body
|
61
|
-
|
61
|
+
# Allow for either standard json content type (ie: application/json)
|
62
|
+
# or a vendor specific type with a json suffix (eg: application/vnd.docker.distribution.events.v2+json)
|
63
|
+
return unless content_type =~ /\Aapplication\/(|.*\+)json/
|
62
64
|
return unless body?
|
63
65
|
|
64
66
|
parse_json_from_string(body.read)
|
data/lib/apia/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: apia
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adam Cooke
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2025-02-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|
@@ -170,7 +170,7 @@ homepage: https://github.com/krystal/apia
|
|
170
170
|
licenses:
|
171
171
|
- MIT
|
172
172
|
metadata: {}
|
173
|
-
post_install_message:
|
173
|
+
post_install_message:
|
174
174
|
rdoc_options: []
|
175
175
|
require_paths:
|
176
176
|
- lib
|
@@ -186,7 +186,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
186
186
|
version: '0'
|
187
187
|
requirements: []
|
188
188
|
rubygems_version: 3.3.27
|
189
|
-
signing_key:
|
189
|
+
signing_key:
|
190
190
|
specification_version: 4
|
191
191
|
summary: This gem provides a friendly DSL for constructing HTTP APIs.
|
192
192
|
test_files: []
|