Class: Utility::Middleware::BasicAuth
- Inherits:
-
Object
- Object
- Utility::Middleware::BasicAuth
- Defined in:
- lib/utility/middleware/basic_auth.rb
Constant Summary collapse
- AUTHORIZATION =
'Authorization'
Instance Attribute Summary collapse
-
#basic_auth_token ⇒ Object
readonly
Returns the value of attribute basic_auth_token.
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app = nil, options = {}) ⇒ BasicAuth
constructor
A new instance of BasicAuth.
Constructor Details
#initialize(app = nil, options = {}) ⇒ BasicAuth
Returns a new instance of BasicAuth.
16 17 18 19 |
# File 'lib/utility/middleware/basic_auth.rb', line 16 def initialize(app = nil, = {}) @app = app @basic_auth_token = .fetch(:basic_auth_token) end |
Instance Attribute Details
#basic_auth_token ⇒ Object (readonly)
Returns the value of attribute basic_auth_token.
14 15 16 |
# File 'lib/utility/middleware/basic_auth.rb', line 14 def basic_auth_token @basic_auth_token end |
Instance Method Details
#call(env) ⇒ Object
21 22 23 24 |
# File 'lib/utility/middleware/basic_auth.rb', line 21 def call(env) env.request_headers[AUTHORIZATION] = "Basic #{basic_auth_token}" @app.call(env) end |