Class: Acmesmith::ChallengeResponders::HttpPath

Inherits:
Base
  • Object
show all
Defined in:
lib/acmesmith/challenge_responders/http_path.rb

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ HttpPath

Returns a new instance of HttpPath.



11
12
13
# File 'lib/acmesmith/challenge_responders/http_path.rb', line 11

def initialize(config)
  @config = config
end

Instance Method Details

#cleanup(domain, challenge) ⇒ Object



21
22
23
24
# File 'lib/acmesmith/challenge_responders/http_path.rb', line 21

def cleanup(domain, challenge)
  puts "=> Cleanup challenge http-01 for #{domain} in #{self.class.name}"
  FileUtils.rm_r( File.join( htdocs_path(domain), File.dirname( challenge.filename ) ) )
end

#htdocs_path(domain) ⇒ Object



26
27
28
29
30
31
32
33
34
# File 'lib/acmesmith/challenge_responders/http_path.rb', line 26

def htdocs_path(domain)
  begin
    htdocs_path = @config[domain.to_sym]['htdocs_path']
  rescue
    raise "cannot read configuration for http_path"
  end

  htdocs_path
end

#respond(domain, challenge) ⇒ Object



15
16
17
18
19
# File 'lib/acmesmith/challenge_responders/http_path.rb', line 15

def respond(domain, challenge)
  puts "=> Responding challenge http-01 for #{domain} in #{self.class.name}"
  FileUtils.mkdir_p( File.join( htdocs_path(domain), File.dirname( challenge.filename ) ) )
  File.write( File.join( htdocs_path(domain), challenge.filename), challenge.file_content )
end

#support?(type) ⇒ Boolean

Returns:

  • (Boolean)


7
8
9
# File 'lib/acmesmith/challenge_responders/http_path.rb', line 7

def support?(type)
  type == 'http-01'
end