class LetsEncryptHerokuClient

Constants

VERSION

Attributes

app[R]

Public Class Methods

new(app) click to toggle source
# File lib/lets_encrypt_heroku_client.rb, line 4
def initialize(app)
  @app = app
end

Public Instance Methods

call(env) click to toggle source
# File lib/lets_encrypt_heroku_client.rb, line 8
def call(env)
  if challenge_url?(env['PATH_INFO'])
    body = ENV['LETS_ENCRYPT_CHALLENGE_FILE_CONTENT']
    headers = {
      'Content-Length' => body.length.to_s
    }

    [200, headers, [body]]
  else
    app.call(env)
  end
end

Private Instance Methods

challenge_url?(path) click to toggle source
# File lib/lets_encrypt_heroku_client.rb, line 25
def challenge_url?(path)
  ENV.include?('LETS_ENCRYPT_CHALLENGE_FILENAME') &&
    path == "/#{ENV['LETS_ENCRYPT_CHALLENGE_FILENAME']}"
end