Class: Tipi::ACME::HTTPChallengeHandler
- Inherits:
-
Object
- Object
- Tipi::ACME::HTTPChallengeHandler
- Defined in:
- lib/tipi/acme.rb
Instance Method Summary collapse
- #add(challenge) ⇒ Object
- #call(req) ⇒ Object
-
#initialize ⇒ HTTPChallengeHandler
constructor
A new instance of HTTPChallengeHandler.
- #remove(challenge) ⇒ Object
Constructor Details
#initialize ⇒ HTTPChallengeHandler
Returns a new instance of HTTPChallengeHandler.
206 207 208 |
# File 'lib/tipi/acme.rb', line 206 def initialize @challenges = {} end |
Instance Method Details
#add(challenge) ⇒ Object
210 211 212 213 |
# File 'lib/tipi/acme.rb', line 210 def add(challenge) path = "/.well-known/acme-challenge/#{challenge.token}" @challenges[path] = challenge end |
#call(req) ⇒ Object
220 221 222 223 224 225 226 227 228 |
# File 'lib/tipi/acme.rb', line 220 def call(req) challenge = @challenges[req.path] # handle incoming request challenge = @challenges[req.path] return req.respond(nil, ':status' => 400) unless challenge req.respond(challenge.file_content, 'content-type' => challenge.content_type) end |
#remove(challenge) ⇒ Object
215 216 217 218 |
# File 'lib/tipi/acme.rb', line 215 def remove(challenge) path = "/.well-known/acme-challenge/#{challenge.token}" @challenges.delete(path) end |