Class: Tipi::ACME::HTTPChallengeHandler

Inherits:
Object
  • Object
show all
Defined in:
lib/tipi/acme.rb

Instance Method Summary collapse

Constructor Details

#initializeHTTPChallengeHandler

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