Class: Drillbit::Requests::Base
- Inherits:
-
Object
- Object
- Drillbit::Requests::Base
- Defined in:
- lib/drillbit/requests/base.rb
Constant Summary collapse
- BASE64_PATTERN =
%r{[A-Za-z0-9_/\+\=\-\.]}
- BASE64_TOKEN_PARAM_NAME =
'token_b64'
- JSON_WEB_TOKEN_PARAM_NAME =
'token_jwt'
- JSON_WEB_TOKEN_PATTERN =
/(#{BASE64_PATTERN}+?\.){4}#{BASE64_PATTERN}+?/
- BASE64_TOKEN_HEADER_PATTERN =
/\A(?:Basic|Bearer)\s+(.*)\z/
- JSON_WEB_TOKEN_HEADER_PATTERN =
/\AToken\s+(.*)\z/
Instance Attribute Summary collapse
-
#request ⇒ Object
Returns the value of attribute request.
-
#token_private_key ⇒ Object
Returns the value of attribute token_private_key.
Class Method Summary collapse
Instance Method Summary collapse
- #accept_header ⇒ Object
- #application_name ⇒ Object
- #authorization_token ⇒ Object
-
#initialize(token_private_key: Drillbit.configuration.token_private_key, request:) ⇒ Base
constructor
A new instance of Base.
- #subdomain ⇒ Object
Constructor Details
#initialize(token_private_key: Drillbit.configuration.token_private_key, request:) ⇒ Base
Returns a new instance of Base.
19 20 21 22 23 24 |
# File 'lib/drillbit/requests/base.rb', line 19 def initialize(token_private_key: Drillbit.configuration.token_private_key, request:) self.token_private_key = token_private_key self.request = request end |
Instance Attribute Details
#request ⇒ Object
Returns the value of attribute request.
16 17 18 |
# File 'lib/drillbit/requests/base.rb', line 16 def request @request end |
#token_private_key ⇒ Object
Returns the value of attribute token_private_key.
16 17 18 |
# File 'lib/drillbit/requests/base.rb', line 16 def token_private_key @token_private_key end |
Class Method Details
.rack_request_class ⇒ Object
77 78 79 80 81 |
# File 'lib/drillbit/requests/base.rb', line 77 def self.rack_request_class require 'drillbit/requests/rack' Object.const_get('Drillbit::Requests::Rack') end |
.rails_request_class ⇒ Object
71 72 73 74 75 |
# File 'lib/drillbit/requests/base.rb', line 71 def self.rails_request_class require 'drillbit/requests/rails' Object.const_get('Drillbit::Requests::Rails') end |
.resolve(original_request) ⇒ Object
61 62 63 64 65 66 67 68 69 |
# File 'lib/drillbit/requests/base.rb', line 61 def self.resolve(original_request) if original_request.is_a? self original_request elsif original_request.respond_to? :headers rails_request_class.new(request: original_request) else rack_request_class.new(request: original_request) end end |
Instance Method Details
#accept_header ⇒ Object
26 27 28 29 30 31 32 33 34 |
# File 'lib/drillbit/requests/base.rb', line 26 def accept_header if accept_header_from_header.valid? || accept_header_from_params.invalid? accept_header_from_header else accept_header_from_params end end |
#application_name ⇒ Object
53 54 55 |
# File 'lib/drillbit/requests/base.rb', line 53 def application_name raw_request_application_name || Drillbit.configuration.application_name end |
#authorization_token ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/drillbit/requests/base.rb', line 36 def if ( !.blank? && .valid? ) \ || ( .blank? || !.valid? ) else end end |
#subdomain ⇒ Object
57 58 59 |
# File 'lib/drillbit/requests/base.rb', line 57 def subdomain @subdomain ||= raw_host[/\A([a-z\-]+)/i, 1] end |