Sha256: ec71ee449f87ab7998a4785c49f9c79f209e026ccae4433c23284271495558c4

Contents?: true

Size: 559 Bytes

Versions: 2

Compression:

Stored size: 559 Bytes

Contents

require 'lets_encrypt_heroku_client/version'

class LetsEncryptHerokuClient
  def initialize(app)
    @app = app
  end

  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

  attr_reader :app

  def challenge_url?(path)
    ENV.include?('LETS_ENCRYPT_CHALLENGE_FILENAME') &&
      path == "/#{ENV['LETS_ENCRYPT_CHALLENGE_FILENAME']}"
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
lets_encrypt_heroku_client-0.1.1 lib/lets_encrypt_heroku_client.rb
lets_encrypt_heroku_client-0.1.0 lib/lets_encrypt_heroku_client.rb