apiphobic-middleware 1.0.1 → 1.1.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
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/lib/apiphobic-middleware.rb +7 -0
- data/lib/apiphobic/matchers/version.rb +40 -0
- data/lib/apiphobic/middleware/configuration.rb +7 -1
- data/lib/apiphobic/middleware/version.rb +1 -1
- metadata +17 -4
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ea2e68845e50dd710e7207df81b3dc11c2103468b581e5dfec8f56405f5bc34d
|
4
|
+
data.tar.gz: '086978783ea45c875a89d8312423fcc80889d5407ef99e069768b003ad821566'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ba24fcbdd61b5f71236a3621672acecc1f64c68c42f20e1644ab0c20c8439ff5a7dfaab8a60b4c74f7cc348091f5bfec87a387cc10ec680d737c701006f7b8b2
|
7
|
+
data.tar.gz: 36d93467b45fa35046bf09340139e27cf51faad6e8190909b45554f03fe43c7489fa4f3674243e3021a58a2c0d8bc7ebe73ccd35f3ac39563feaf3a54184ed1f
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/lib/apiphobic-middleware.rb
CHANGED
@@ -1,3 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'apiphobic/matchers/version'
|
4
|
+
require 'apiphobic/middleware/configuration'
|
5
|
+
require 'apiphobic/middleware/converters/content_type'
|
6
|
+
require 'apiphobic/middleware/converters/json_api_parameters'
|
7
|
+
require 'apiphobic/middleware/validators/accept_header'
|
8
|
+
require 'apiphobic/middleware/validators/authorization_token'
|
9
|
+
require 'apiphobic/middleware/validators/subdomain'
|
3
10
|
require 'apiphobic/middleware/version'
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'apiphobic/middleware/configurable'
|
4
|
+
|
5
|
+
module Apiphobic
|
6
|
+
module Matchers
|
7
|
+
class Version
|
8
|
+
include Middleware::Configurable
|
9
|
+
|
10
|
+
attr_accessor :accept_header,
|
11
|
+
:application_name,
|
12
|
+
:default_version,
|
13
|
+
:request,
|
14
|
+
:version_constraint
|
15
|
+
|
16
|
+
def initialize(version_constraint:,
|
17
|
+
application_name: configuration.application_name,
|
18
|
+
default_version: configuration.default_api_version)
|
19
|
+
|
20
|
+
self.application_name = application_name
|
21
|
+
self.default_version = default_version
|
22
|
+
self.version_constraint = version_constraint
|
23
|
+
end
|
24
|
+
|
25
|
+
def matches?(request)
|
26
|
+
self.request = request
|
27
|
+
self.accept_header = ::Apiphobic::AcceptHeader.new(request.accept_header,
|
28
|
+
application_name: application_name)
|
29
|
+
|
30
|
+
requested_version == version_constraint
|
31
|
+
end
|
32
|
+
|
33
|
+
private
|
34
|
+
|
35
|
+
def requested_version
|
36
|
+
accept_header.version || default_version
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -9,13 +9,15 @@ module Middleware
|
|
9
9
|
|
10
10
|
attr_accessor :application_name
|
11
11
|
attr_writer :allowed_api_subdomains,
|
12
|
-
:allowed_subdomains
|
12
|
+
:allowed_subdomains,
|
13
|
+
:default_api_version
|
13
14
|
|
14
15
|
def to_h
|
15
16
|
{
|
16
17
|
allowed_api_subdomains: allowed_api_subdomains,
|
17
18
|
allowed_subdomains: allowed_subdomains,
|
18
19
|
application_name: application_name,
|
20
|
+
default_api_version: default_api_version,
|
19
21
|
}
|
20
22
|
end
|
21
23
|
|
@@ -26,6 +28,10 @@ module Middleware
|
|
26
28
|
def allowed_api_subdomains
|
27
29
|
@allowed_api_subdomains || ['api']
|
28
30
|
end
|
31
|
+
|
32
|
+
def default_api_version
|
33
|
+
@default_api_version || '1'
|
34
|
+
end
|
29
35
|
end
|
30
36
|
|
31
37
|
def self.configure
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: apiphobic-middleware
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- thegranddesign
|
@@ -31,7 +31,7 @@ cert_chain:
|
|
31
31
|
Y2GAoHKstmfIVhc4XHOPpmTd2o/C29O9oaRgjrkfQEhF/KvJ/PhoV5hvokzsCyI5
|
32
32
|
iUeXPfvrGD/itYIBCgk+fnzyQQ4QtE5hTQaWQ3o2
|
33
33
|
-----END CERTIFICATE-----
|
34
|
-
date: 2018-05-
|
34
|
+
date: 2018-05-04 00:00:00.000000000 Z
|
35
35
|
dependencies:
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: apple_core
|
@@ -39,18 +39,21 @@ dependencies:
|
|
39
39
|
requirements:
|
40
40
|
- - "~>"
|
41
41
|
- !ruby/object:Gem::Version
|
42
|
-
version: '1.
|
42
|
+
version: '1.3'
|
43
43
|
type: :runtime
|
44
44
|
prerelease: false
|
45
45
|
version_requirements: !ruby/object:Gem::Requirement
|
46
46
|
requirements:
|
47
47
|
- - "~>"
|
48
48
|
- !ruby/object:Gem::Version
|
49
|
-
version: '1.
|
49
|
+
version: '1.3'
|
50
50
|
- !ruby/object:Gem::Dependency
|
51
51
|
name: apiphobic-tokens
|
52
52
|
requirement: !ruby/object:Gem::Requirement
|
53
53
|
requirements:
|
54
|
+
- - ">="
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: 1.0.1
|
54
57
|
- - "~>"
|
55
58
|
- !ruby/object:Gem::Version
|
56
59
|
version: '1.0'
|
@@ -58,6 +61,9 @@ dependencies:
|
|
58
61
|
prerelease: false
|
59
62
|
version_requirements: !ruby/object:Gem::Requirement
|
60
63
|
requirements:
|
64
|
+
- - ">="
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: 1.0.1
|
61
67
|
- - "~>"
|
62
68
|
- !ruby/object:Gem::Version
|
63
69
|
version: '1.0'
|
@@ -65,6 +71,9 @@ dependencies:
|
|
65
71
|
name: erratum
|
66
72
|
requirement: !ruby/object:Gem::Requirement
|
67
73
|
requirements:
|
74
|
+
- - ">="
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: 3.1.1
|
68
77
|
- - "~>"
|
69
78
|
- !ruby/object:Gem::Version
|
70
79
|
version: '3.1'
|
@@ -72,6 +81,9 @@ dependencies:
|
|
72
81
|
prerelease: false
|
73
82
|
version_requirements: !ruby/object:Gem::Requirement
|
74
83
|
requirements:
|
84
|
+
- - ">="
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
version: 3.1.1
|
75
87
|
- - "~>"
|
76
88
|
- !ruby/object:Gem::Version
|
77
89
|
version: '3.1'
|
@@ -133,6 +145,7 @@ files:
|
|
133
145
|
- lib/apiphobic/errors/invalid_subdomain.rb
|
134
146
|
- lib/apiphobic/matchers/accept_header.rb
|
135
147
|
- lib/apiphobic/matchers/subdomain.rb
|
148
|
+
- lib/apiphobic/matchers/version.rb
|
136
149
|
- lib/apiphobic/middleware/configurable.rb
|
137
150
|
- lib/apiphobic/middleware/configuration.rb
|
138
151
|
- lib/apiphobic/middleware/converters/content_type.rb
|
metadata.gz.sig
CHANGED
Binary file
|