Class: Acme::Client::HTTPClient::AcmeMiddleware
- Inherits:
-
Faraday::Middleware
- Object
- Faraday::Middleware
- Acme::Client::HTTPClient::AcmeMiddleware
- Defined in:
- lib/acme/client/http_client.rb
Overview
AcmeMiddleware implements the Acme-protocol requirements for JWK requests.
Constant Summary collapse
- CONTENT_TYPE =
'application/jose+json'
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
-
#env ⇒ Object
readonly
Returns the value of attribute env.
-
#response ⇒ Object
readonly
Returns the value of attribute response.
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, options) ⇒ AcmeMiddleware
constructor
A new instance of AcmeMiddleware.
- #on_complete(env) ⇒ Object
Constructor Details
#initialize(app, options) ⇒ AcmeMiddleware
Returns a new instance of AcmeMiddleware.
61 62 63 64 65 |
# File 'lib/acme/client/http_client.rb', line 61 def initialize(app, ) super(app) @client = .fetch(:client) @mode = .fetch(:mode) end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
57 58 59 |
# File 'lib/acme/client/http_client.rb', line 57 def client @client end |
#env ⇒ Object (readonly)
Returns the value of attribute env.
57 58 59 |
# File 'lib/acme/client/http_client.rb', line 57 def env @env end |
#response ⇒ Object (readonly)
Returns the value of attribute response.
57 58 59 |
# File 'lib/acme/client/http_client.rb', line 57 def response @response end |
Instance Method Details
#call(env) ⇒ Object
67 68 69 70 71 72 73 74 75 76 |
# File 'lib/acme/client/http_client.rb', line 67 def call(env) @env = env @env[:request_headers]['Content-Type'] = CONTENT_TYPE if @env.method != :get @env.body = client.jwk.jws(header: jws_header, payload: env.body) end @app.call(env).on_complete { |response_env| on_complete(response_env) } end |
#on_complete(env) ⇒ Object
78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/acme/client/http_client.rb', line 78 def on_complete(env) @env = env raise_on_not_found! store_nonce env.body = decode_body env.response_headers['Link'] = decode_link_headers return if env.success? raise_on_error! end |