Class: JWTSignedRequest::Middlewares::Faraday
- Inherits:
-
Faraday::Middleware
- Object
- Faraday::Middleware
- JWTSignedRequest::Middlewares::Faraday
- Defined in:
- lib/jwt_signed_request/middlewares/faraday.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, bearer_schema: nil, **options) ⇒ Faraday
constructor
A new instance of Faraday.
Constructor Details
#initialize(app, bearer_schema: nil, **options) ⇒ Faraday
Returns a new instance of Faraday.
9 10 11 12 13 14 |
# File 'lib/jwt_signed_request/middlewares/faraday.rb', line 9 def initialize(app, bearer_schema: nil, **) @bearer_schema = bearer_schema @options = ? super(app, ) : super(app) end |
Instance Method Details
#call(env) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/jwt_signed_request/middlewares/faraday.rb', line 16 def call(env) env[:body] ||= ::JWTSignedRequest::EMPTY_BODY @jwt_token = ::JWTSignedRequest.sign( method: env[:method], path: env[:url].request_uri, headers: env[:request_headers], body: env[:body], **, ) env[:request_headers].store("Authorization", ) app.call(env) end |