apill 2.1.0 → 2.2.0

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
  SHA1:
3
- metadata.gz: 324554154383f6408cffde10e537effa59d4b928
4
- data.tar.gz: c5b4dbfa7b10c87ae1861526fcda7eb6a1a55016
3
+ metadata.gz: 83d6429288497499ef52987e7f8f9a5c8d8c7f6c
4
+ data.tar.gz: a07b1f22022080022b72665a07b212c58aba56d4
5
5
  SHA512:
6
- metadata.gz: 8e5ba589f30445e86f402e2aefb0c9ea22b5dda8943a85bcf612a98fd48128c52749ab069cb267d267159143211d24bbf826c86d26905e895eab1a5d5210a07d
7
- data.tar.gz: 8adaaa7dbf3dc3dba76f6be72503fc9b14973e82d5a726ad4591f9dbedbb76725f9c069c28ac71dba9b13fb37a03fe348fd4761cb034c3131797e5df42dc72ca
6
+ metadata.gz: 80896fdee5a9fd08bf3ba02449d54d481415ccb6fa82424312fa3aaa329bcaf1492ac14d93f4f7bca224cbe7cc78f2da21210f5e07b9992887dfcce8d6f3bb3d
7
+ data.tar.gz: 875abc5d8d8999fe9e649f2fde48305c2f822ecdc820ba2aad2c7f8d79aa906eb69b9a135bfb3129d8ff55458be3f294ba20d53dad75727111786c5de8641acf
@@ -17,7 +17,15 @@ class AcceptHeader
17
17
  end
18
18
 
19
19
  def valid?
20
- !accept_header_data.nil?
20
+ !invalid?
21
+ end
22
+
23
+ def invalid?
24
+ accept_header_data.nil?
25
+ end
26
+
27
+ def to_s
28
+ raw_accept_header
21
29
  end
22
30
 
23
31
  private
@@ -14,6 +14,10 @@ module Apill
14
14
  end
15
15
  end
16
16
 
17
+ def allowed_subdomains
18
+ @allowed_subdomains || ['api']
19
+ end
20
+
17
21
  def self.configure
18
22
  yield configuration
19
23
  end
@@ -1,4 +1,5 @@
1
1
  require 'apill/accept_header'
2
+ require 'apill/requests/base'
2
3
 
3
4
  module Apill
4
5
  module Matchers
@@ -13,31 +14,9 @@ module GenericMatcher
13
14
  end
14
15
 
15
16
  def matches?(request)
16
- self.application = request['API_APPLICATION_NAME']
17
- self.accept_header = get_accept_header(raw_header_from_headers: request['HTTP_ACCEPT'],
18
- raw_header_from_params: request['QUERY_STRING'])
19
- end
20
-
21
- private
22
-
23
- def get_accept_header(raw_header_from_headers:, raw_header_from_params:)
24
- header_from_header = accept_header_from_string(raw_header_from_headers)
25
-
26
- return header_from_header if header_from_header.valid? ||
27
- raw_header_from_params.to_s.empty?
28
-
29
- accept_header_from_params(raw_header_from_params)
30
- end
31
-
32
- def accept_header_from_string(raw_header_from_headers='')
33
- Apill::AcceptHeader.new(application: application,
34
- header: raw_header_from_headers)
35
- end
36
-
37
- def accept_header_from_params(raw_header_from_params='')
38
- header_from_params = raw_header_from_params[%r{(?:\A|&)accept=(.+?)(?=\z|&)}, 1]
39
-
40
- accept_header_from_string(header_from_params)
17
+ request = Requests::Base.resolve(request)
18
+ self.application = request.application_name
19
+ self.accept_header = request.accept_header
41
20
  end
42
21
  end
43
22
  end
@@ -1,7 +1,7 @@
1
1
  module Apill
2
2
  module Matchers
3
3
  class SubdomainMatcher
4
- def initialize(allowed_subdomains: ['api'])
4
+ def initialize(allowed_subdomains: Apill.configuration.allowed_subdomains)
5
5
  self.allowed_subdomains = Array(allowed_subdomains)
6
6
  end
7
7
 
@@ -4,7 +4,7 @@ require 'apill/matchers/generic_matcher'
4
4
  module Apill
5
5
  module Matchers
6
6
  class VersionMatcher
7
- include Apill::Matchers::GenericMatcher
7
+ include GenericMatcher
8
8
 
9
9
  attr_accessor :version_constraint,
10
10
  :default_version
@@ -13,11 +13,9 @@ class ApiRequest
13
13
  end
14
14
 
15
15
  def call(env)
16
- env['API_APPLICATION_NAME'] = Apill.configuration.application_name
17
-
18
- if Matchers::SubdomainMatcher.new(allowed_subdomains: Apill.configuration.allowed_subdomains).
19
- matches?(env)
16
+ env['HTTP_X_APPLICATION_NAME'] = Apill.configuration.application_name
20
17
 
18
+ if Matchers::SubdomainMatcher.new.matches?(env)
21
19
  if Matchers::AcceptHeaderMatcher.new.matches?(env)
22
20
  @app.call(env)
23
21
  else
@@ -0,0 +1,37 @@
1
+ module Apill
2
+ module Requests
3
+ class Base
4
+ def self.resolve(original_request)
5
+ if original_request.respond_to? :headers
6
+ rails_request_class.new(original_request)
7
+ else
8
+ rack_request_class.new(original_request)
9
+ end
10
+ end
11
+
12
+ def accept_header
13
+ if accept_header_from_header.valid? ||
14
+ accept_header_from_params.invalid?
15
+
16
+ accept_header_from_header
17
+ else
18
+ accept_header_from_params
19
+ end
20
+ end
21
+
22
+ private
23
+
24
+ def self.rails_request_class
25
+ require 'apill/requests/rails_request'
26
+
27
+ Object.const_get('Apill::Requests::RailsRequest')
28
+ end
29
+
30
+ def self.rack_request_class
31
+ require 'apill/requests/rack_request'
32
+
33
+ Object.const_get('Apill::Requests::RackRequest')
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,37 @@
1
+ require 'apill/configuration'
2
+ require 'apill/requests/base'
3
+ require 'apill/accept_header'
4
+
5
+ module Apill
6
+ module Requests
7
+ class RackRequest < Base
8
+ ACCEPT_PARAM_PATTERN = %r{(?:\A|&)accept=(.+?)(?=\z|&)}
9
+
10
+ attr_accessor :request
11
+
12
+ def initialize(request)
13
+ self.request = request
14
+ end
15
+
16
+ def accept_header_from_header
17
+ AcceptHeader.new(application: application_name,
18
+ header: request['HTTP_ACCEPT'] || '')
19
+ end
20
+
21
+ def accept_header_from_params
22
+ AcceptHeader.new(application: application_name,
23
+ header: raw_accept_header_from_params || '')
24
+ end
25
+
26
+ def application_name
27
+ request['HTTP_X_APPLICATION_NAME'] || Apill.configuration.application_name
28
+ end
29
+
30
+ private
31
+
32
+ def raw_accept_header_from_params
33
+ request['QUERY_STRING'][ACCEPT_PARAM_PATTERN, 1]
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,29 @@
1
+ require 'apill/configuration'
2
+ require 'apill/requests/base'
3
+ require 'apill/accept_header'
4
+
5
+ module Apill
6
+ module Requests
7
+ class RailsRequest < Base
8
+ attr_accessor :request
9
+
10
+ def initialize(request)
11
+ self.request = request
12
+ end
13
+
14
+ def accept_header_from_header
15
+ AcceptHeader.new(application: application_name,
16
+ header: request.headers['Accept'] || '')
17
+ end
18
+
19
+ def accept_header_from_params
20
+ AcceptHeader.new(application: application_name,
21
+ header: request.params['accept'] || '')
22
+ end
23
+
24
+ def application_name
25
+ request.headers['X-Application-Name'] || Apill.configuration.application_name
26
+ end
27
+ end
28
+ end
29
+ end
data/lib/apill/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Apill
2
- VERSION = '2.1.0'
2
+ VERSION = '2.2.0'
3
3
  end
@@ -6,8 +6,8 @@ module Matchers
6
6
  describe AcceptHeaderMatcher do
7
7
  it 'matches if the subdomain is API and the accept header is valid' do
8
8
  request = {
9
- 'HTTP_ACCEPT' => 'application/vnd.matrix+zion;version=1.0.0',
10
- 'API_APPLICATION_NAME' => 'matrix',
9
+ 'HTTP_ACCEPT' => 'application/vnd.matrix+zion;version=1.0.0',
10
+ 'HTTP_X_APPLICATION_NAME' => 'matrix',
11
11
  }
12
12
 
13
13
  matcher = AcceptHeaderMatcher.new
@@ -19,8 +19,8 @@ describe AcceptHeaderMatcher do
19
19
  'a parameter' do
20
20
 
21
21
  request = {
22
- 'QUERY_STRING' => 'accept=application/vnd.matrix+zion;version=1.0.0',
23
- 'API_APPLICATION_NAME' => 'matrix',
22
+ 'QUERY_STRING' => 'accept=application/vnd.matrix+zion;version=1.0.0',
23
+ 'HTTP_X_APPLICATION_NAME' => 'matrix',
24
24
  }
25
25
 
26
26
  matcher = AcceptHeaderMatcher.new
@@ -32,8 +32,8 @@ describe AcceptHeaderMatcher do
32
32
  'secondary parameter' do
33
33
 
34
34
  request = {
35
- 'QUERY_STRING' => 'first=my_param&accept=application/vnd.matrix+zion;version=1.0.0',
36
- 'API_APPLICATION_NAME' => 'matrix',
35
+ 'QUERY_STRING' => 'first=my_param&accept=application/vnd.matrix+zion;version=1.0.0',
36
+ 'HTTP_X_APPLICATION_NAME' => 'matrix',
37
37
  }
38
38
 
39
39
  matcher = AcceptHeaderMatcher.new
@@ -45,9 +45,9 @@ describe AcceptHeaderMatcher do
45
45
  'is passed both as a valid header and as a parameter' do
46
46
 
47
47
  request = {
48
- 'HTTP_ACCEPT' => 'application/vnd.matrix+zion;version=1.0.0',
49
- 'QUERY_STRING' => 'accept=application/vnd.matrix+zion;version=2.0.0',
50
- 'API_APPLICATION_NAME' => 'matrix',
48
+ 'HTTP_ACCEPT' => 'application/vnd.matrix+zion;version=1.0.0',
49
+ 'QUERY_STRING' => 'accept=application/vnd.matrix+zion;version=2.0.0',
50
+ 'HTTP_X_APPLICATION_NAME' => 'matrix',
51
51
  }
52
52
 
53
53
  matcher = AcceptHeaderMatcher.new
@@ -60,9 +60,9 @@ describe AcceptHeaderMatcher do
60
60
  'header is passed both as an invalid header as well as as a parameter' do
61
61
 
62
62
  request = {
63
- 'HTTP_ACCEPT' => 'application/vndmatrix+zion;version=1.0.0',
64
- 'QUERY_STRING' => 'accept=application/vnd.matrix+zion;version=2.0.0',
65
- 'API_APPLICATION_NAME' => 'matrix',
63
+ 'HTTP_ACCEPT' => 'application/vndmatrix+zion;version=1.0.0',
64
+ 'QUERY_STRING' => 'accept=application/vnd.matrix+zion;version=2.0.0',
65
+ 'HTTP_X_APPLICATION_NAME' => 'matrix',
66
66
  }
67
67
 
68
68
  matcher = AcceptHeaderMatcher.new
@@ -75,9 +75,9 @@ describe AcceptHeaderMatcher do
75
75
  'header is passed both as an invalid header as well as as a parameter' do
76
76
 
77
77
  request = {
78
- 'HTTP_ACCEPT' => 'application/vndmatrix+zion;version=1.0.0',
79
- 'QUERY_STRING' => '',
80
- 'API_APPLICATION_NAME' => 'matrix',
78
+ 'HTTP_ACCEPT' => 'application/vndmatrix+zion;version=1.0.0',
79
+ 'QUERY_STRING' => '',
80
+ 'HTTP_X_APPLICATION_NAME' => 'matrix',
81
81
  }
82
82
 
83
83
  matcher = AcceptHeaderMatcher.new
@@ -89,9 +89,9 @@ describe AcceptHeaderMatcher do
89
89
 
90
90
  it 'does not match if the subdomain is API but the accept header is invalid' do
91
91
  request = {
92
- 'HTTP_ACCEPT' => 'application/vndmatrix+zion;version=1.0.0',
93
- 'QUERY_STRING' => '',
94
- 'API_APPLICATION_NAME' => 'matrix',
92
+ 'HTTP_ACCEPT' => 'application/vndmatrix+zion;version=1.0.0',
93
+ 'QUERY_STRING' => '',
94
+ 'HTTP_X_APPLICATION_NAME' => 'matrix',
95
95
  }
96
96
 
97
97
  matcher = AcceptHeaderMatcher.new
@@ -7,9 +7,9 @@ module Matchers
7
7
  describe InvalidApiRequestMatcher do
8
8
  it 'is the inverse of whether the accept header matches' do
9
9
  request = {
10
- 'HTTP_HOST' => 'api.example.com',
11
- 'HTTP_ACCEPT' => 'application/vnd.matrix+zion;version=1.0.0',
12
- 'API_APPLICATION_NAME' => 'matrix',
10
+ 'HTTP_HOST' => 'api.example.com',
11
+ 'HTTP_ACCEPT' => 'application/vnd.matrix+zion;version=1.0.0',
12
+ 'HTTP_X_APPLICATION_NAME' => 'matrix',
13
13
  }
14
14
 
15
15
  matcher = InvalidApiRequestMatcher.new
@@ -4,6 +4,10 @@ require 'apill/matchers/subdomain_matcher'
4
4
  module Apill
5
5
  module Matchers
6
6
  describe SubdomainMatcher do
7
+ before(:each) do
8
+ Apill.configuration.allowed_subdomains = %w{api}
9
+ end
10
+
7
11
  it 'matches if the subdomain is API' do
8
12
  matcher = SubdomainMatcher.new
9
13
  request = { 'HTTP_HOST' => 'api.example.com' }
@@ -9,8 +9,8 @@ describe VersionMatcher do
9
9
  'equal the version constraint' do
10
10
 
11
11
  request = {
12
- 'API_APPLICATION_NAME' => 'matrix',
13
- 'HTTP_ACCEPT' => 'application/vnd.matrix+zion;version=10.0',
12
+ 'HTTP_X_APPLICATION_NAME' => 'matrix',
13
+ 'HTTP_ACCEPT' => 'application/vnd.matrix+zion;version=10.0',
14
14
  }
15
15
 
16
16
  matcher = VersionMatcher.new(version_constraint: '10.1')
@@ -22,8 +22,8 @@ describe VersionMatcher do
22
22
  'version constraint' do
23
23
 
24
24
  request = {
25
- 'API_APPLICATION_NAME' => 'matrix',
26
- 'HTTP_ACCEPT' => 'application/vnd.matrix+zion;version=10.0',
25
+ 'HTTP_X_APPLICATION_NAME' => 'matrix',
26
+ 'HTTP_ACCEPT' => 'application/vnd.matrix+zion;version=10.0',
27
27
  }
28
28
 
29
29
  matcher = VersionMatcher.new(version_constraint: '10.0')
@@ -37,8 +37,8 @@ describe VersionMatcher do
37
37
  'equal the version constraint' do
38
38
 
39
39
  request = {
40
- 'API_APPLICATION_NAME' => 'matrix',
41
- 'HTTP_ACCEPT' => 'application/vnd.matrix+zion',
40
+ 'HTTP_X_APPLICATION_NAME' => 'matrix',
41
+ 'HTTP_ACCEPT' => 'application/vnd.matrix+zion',
42
42
  }
43
43
 
44
44
  matcher = VersionMatcher.new(version_constraint: '10.1',
@@ -51,8 +51,8 @@ describe VersionMatcher do
51
51
  'version constraint' do
52
52
 
53
53
  request = {
54
- 'API_APPLICATION_NAME' => 'matrix',
55
- 'HTTP_ACCEPT' => 'application/vnd.matrix+zion',
54
+ 'HTTP_X_APPLICATION_NAME' => 'matrix',
55
+ 'HTTP_ACCEPT' => 'application/vnd.matrix+zion',
56
56
  }
57
57
 
58
58
  matcher = VersionMatcher.new(version_constraint: '10.0',
@@ -66,8 +66,8 @@ describe VersionMatcher do
66
66
  Apill.configuration.default_api_version = '100.0'
67
67
 
68
68
  request = {
69
- 'API_APPLICATION_NAME' => 'matrix',
70
- 'HTTP_ACCEPT' => 'application/vnd.matrix+zion',
69
+ 'HTTP_X_APPLICATION_NAME' => 'matrix',
70
+ 'HTTP_ACCEPT' => 'application/vnd.matrix+zion',
71
71
  }
72
72
 
73
73
  matcher = VersionMatcher.new(version_constraint: '100.0')
@@ -1,30 +1,31 @@
1
1
  require 'rspectacular'
2
2
  require 'apill/middleware/api_request'
3
3
 
4
- HumanError.configure do |config|
5
- config.api_error_documentation_url = 'http://error.com'
6
- config.knowledgebase_url = 'http://knowledge.com'
7
- config.api_version = '1'
8
- end
9
-
10
- Apill.configure do |config|
11
- config.allowed_subdomains = %w{api}
12
- config.application_name = 'matrix'
13
- end
14
-
15
4
  module Apill
16
5
  module Middleware
17
6
  describe ApiRequest do
18
7
  let(:app) { lambda { |env| [200, {}, 'response'] } }
19
8
 
9
+ before(:each) do
10
+ HumanError.configure do |config|
11
+ config.api_error_documentation_url = 'http://error.com'
12
+ config.knowledgebase_url = 'http://knowledge.com'
13
+ config.api_version = '1'
14
+ end
15
+
16
+ Apill.configure do |config|
17
+ config.allowed_subdomains = %w{api}
18
+ config.application_name = 'matrix'
19
+ end
20
+ end
21
+
20
22
  it 'does not allow requests if they are not for an allowed subdomain' do
21
23
  api_request_middleware = ApiRequest.new(app)
22
24
 
23
25
  request = {
24
- 'HTTP_HOST' => 'notvalid.example.com',
25
- 'HTTP_ACCEPT' => '',
26
- 'QUERY_STRING' => 'first=my_param&accept=application/vnd.silent+zion;version=1.0.0',
27
- 'API_APPLICATION_NAME' => 'matrix',
26
+ 'HTTP_HOST' => 'notvalid.example.com',
27
+ 'HTTP_ACCEPT' => '',
28
+ 'QUERY_STRING' => 'first=my_param&accept=application/vnd.silent+zion;version=1.0.0',
28
29
  }
29
30
 
30
31
  status, headers, response = api_request_middleware.call(request)
@@ -60,10 +61,9 @@ describe ApiRequest do
60
61
  api_request_middleware = ApiRequest.new(app)
61
62
 
62
63
  request = {
63
- 'HTTP_HOST' => 'api.example.com',
64
- 'HTTP_ACCEPT' => '',
65
- 'QUERY_STRING' => 'first=my_param&accept=application/vnd.silent+zion;version=1.0.0',
66
- 'API_APPLICATION_NAME' => 'matrix',
64
+ 'HTTP_HOST' => 'api.example.com',
65
+ 'HTTP_ACCEPT' => '',
66
+ 'QUERY_STRING' => 'first=my_param&accept=application/vnd.silent+zion;version=1.0.0',
67
67
  }
68
68
 
69
69
  status, headers, response = api_request_middleware.call(request)
@@ -97,10 +97,9 @@ describe ApiRequest do
97
97
  api_request_middleware = ApiRequest.new(app)
98
98
 
99
99
  request = {
100
- 'HTTP_HOST' => 'api.example.com',
101
- 'HTTP_ACCEPT' => 'application/vnd.matrix+zion;version=1.0.0',
102
- 'QUERY_STRING' => 'first=my_param&accept=application/vnd.matrix+zion;version=1.0.0',
103
- 'API_APPLICATION_NAME' => 'matrix',
100
+ 'HTTP_HOST' => 'api.example.com',
101
+ 'HTTP_ACCEPT' => 'application/vnd.matrix+zion;version=1.0.0',
102
+ 'QUERY_STRING' => 'first=my_param&accept=application/vnd.matrix+zion;version=1.0.0',
104
103
  }
105
104
 
106
105
  status, headers, response = api_request_middleware.call(request)
@@ -0,0 +1,57 @@
1
+ require 'rspectacular'
2
+ require 'apill/requests/rack_request'
3
+
4
+ module Apill
5
+ module Requests
6
+ describe RackRequest do
7
+ it 'finds the accept header from the headers if it is valid' do
8
+ raw_request = {
9
+ 'HTTP_ACCEPT' => 'application/vnd.matrix+zion;version=10.0',
10
+ 'QUERY_STRING' => '',
11
+ 'HTTP_X_APPLICATION_NAME' => 'matrix',
12
+ }
13
+ request = RackRequest.new(raw_request)
14
+
15
+ expect(request.accept_header.to_s).to eql 'application/vnd.matrix+zion;version=10.0'
16
+ end
17
+
18
+ it 'finds the accept header from the headers if it is invalid but there is no ' \
19
+ 'accept header in the params' do
20
+
21
+ raw_request = {
22
+ 'HTTP_ACCEPT' => 'invalid/vnd.matrix+zion;version=10.0',
23
+ 'QUERY_STRING' => '',
24
+ 'HTTP_X_APPLICATION_NAME' => 'matrix',
25
+ }
26
+ request = RackRequest.new(raw_request)
27
+
28
+ expect(request.accept_header.to_s).to eql 'invalid/vnd.matrix+zion;version=10.0'
29
+ end
30
+
31
+ it 'finds the accept header from the params if it is valid' do
32
+ raw_request = {
33
+ 'HTTP_ACCEPT' => '',
34
+ 'QUERY_STRING' => 'accept=application/vnd.matrix+zion;version=10.0',
35
+ 'HTTP_X_APPLICATION_NAME' => 'matrix',
36
+ }
37
+ request = RackRequest.new(raw_request)
38
+
39
+ expect(request.accept_header.to_s).to eql 'application/vnd.matrix+zion;version=10.0'
40
+ end
41
+
42
+ it 'defaults to the application name in the configuration if none is found in ' \
43
+ 'the header' do
44
+
45
+ Apill.configuration.application_name = 'zion'
46
+
47
+ raw_request = {
48
+ 'HTTP_ACCEPT' => '',
49
+ 'QUERY_STRING' => 'accept=application/vnd.zion+zion;version=10.0',
50
+ }
51
+ request = RackRequest.new(raw_request)
52
+
53
+ expect(request.accept_header.to_s).to eql 'application/vnd.zion+zion;version=10.0'
54
+ end
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,59 @@
1
+ require 'ostruct'
2
+ require 'rspectacular'
3
+ require 'apill/requests/rails_request'
4
+
5
+ module Apill
6
+ module Requests
7
+ describe RailsRequest do
8
+ it 'finds the accept header from the headers if it is valid' do
9
+ raw_request = OpenStruct.new(
10
+ headers: {
11
+ 'X-Application-Name' => 'matrix',
12
+ 'Accept' => 'application/vnd.matrix+zion;version=10.0',
13
+ },
14
+ params: {})
15
+ request = RailsRequest.new(raw_request)
16
+
17
+ expect(request.accept_header.to_s).to eql 'application/vnd.matrix+zion;version=10.0'
18
+ end
19
+
20
+ it 'finds the accept header from the headers if it is invalid but there is no ' \
21
+ 'accept header in the params' do
22
+
23
+ raw_request = OpenStruct.new(
24
+ headers: {
25
+ 'X-Application-Name' => 'matrix',
26
+ 'Accept' => 'invalid/vnd.matrix+zion;version=10.0',
27
+ },
28
+ params: {})
29
+ request = RailsRequest.new(raw_request)
30
+
31
+ expect(request.accept_header.to_s).to eql 'invalid/vnd.matrix+zion;version=10.0'
32
+ end
33
+
34
+ it 'finds the accept header from the params if it is valid' do
35
+ raw_request = OpenStruct.new(
36
+ headers: {
37
+ 'X-Application-Name' => 'matrix',
38
+ },
39
+ params: { 'accept' => 'application/vnd.matrix+zion;version=10.0' })
40
+ request = RailsRequest.new(raw_request)
41
+
42
+ expect(request.accept_header.to_s).to eql 'application/vnd.matrix+zion;version=10.0'
43
+ end
44
+
45
+ it 'defaults to the application name in the configuration if none is found in ' \
46
+ 'the header' do
47
+
48
+ Apill.configuration.application_name = 'zion'
49
+
50
+ raw_request = OpenStruct.new(
51
+ headers: {},
52
+ params: { 'accept' => 'application/vnd.zion+zion;version=10.0' })
53
+ request = RailsRequest.new(raw_request)
54
+
55
+ expect(request.accept_header.to_s).to eql 'application/vnd.zion+zion;version=10.0'
56
+ end
57
+ end
58
+ end
59
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: apill
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.0
4
+ version: 2.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - jfelchner
@@ -86,6 +86,9 @@ files:
86
86
  - lib/apill/matchers/subdomain_matcher.rb
87
87
  - lib/apill/matchers/version_matcher.rb
88
88
  - lib/apill/middleware/api_request.rb
89
+ - lib/apill/requests/base.rb
90
+ - lib/apill/requests/rack_request.rb
91
+ - lib/apill/requests/rails_request.rb
89
92
  - lib/apill/responses/invalid_api_request_response.rb
90
93
  - lib/apill/responses/invalid_subdomain_response.rb
91
94
  - lib/apill/version.rb
@@ -98,6 +101,8 @@ files:
98
101
  - spec/apill/matchers/subdomain_matcher_spec.rb
99
102
  - spec/apill/matchers/version_matcher_spec.rb
100
103
  - spec/apill/middleware/api_request_spec.rb
104
+ - spec/apill/requests/rack_request_spec.rb
105
+ - spec/apill/requests/rails_request_spec.rb
101
106
  homepage: https://github.com/jfelchner/apill
102
107
  licenses:
103
108
  - MIT
@@ -132,4 +137,6 @@ test_files:
132
137
  - spec/apill/matchers/subdomain_matcher_spec.rb
133
138
  - spec/apill/matchers/version_matcher_spec.rb
134
139
  - spec/apill/middleware/api_request_spec.rb
140
+ - spec/apill/requests/rack_request_spec.rb
141
+ - spec/apill/requests/rails_request_spec.rb
135
142
  has_rdoc: