Class: Puma::Acme::Middleware
- Inherits:
-
Object
- Object
- Puma::Acme::Middleware
- Defined in:
- lib/puma/acme/middleware.rb
Overview
ACME challenge response handler for HTTP-01 challenges.
Instance Method Summary collapse
- #_call(env) ⇒ Object
- #call(env) ⇒ Object
-
#initialize(app, manager:) ⇒ Middleware
constructor
A new instance of Middleware.
Constructor Details
#initialize(app, manager:) ⇒ Middleware
Returns a new instance of Middleware.
7 8 9 10 |
# File 'lib/puma/acme/middleware.rb', line 7 def initialize(app, manager:) @app = app @manager = manager end |
Instance Method Details
#_call(env) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/puma/acme/middleware.rb', line 16 def _call(env) if (token = token(env)).nil? return @app.call(env) end if (answer = @manager.answer(type: CHALLENGE_TYPE, token: token)).nil? return @app.call(env) end [200, {'content-type' => 'text/plain;charset=utf-8'}, [answer.value]] end |
#call(env) ⇒ Object
12 13 14 |
# File 'lib/puma/acme/middleware.rb', line 12 def call(env) dup._call(env) end |