Sha256: 55b68ee6a3289348d6b89ee58df06abda2a115378dcd64eda498a4e0700a00fd

Contents?: true

Size: 904 Bytes

Versions: 1

Compression:

Stored size: 904 Bytes

Contents

require 'faraday'

module Verndari
  class Congress

    def initialize(app)
      @app = app
    end

    # Verndari.configure do |config|
    #   config.host = "sirdab.co"
    #   config.email = 'notifications@sirdab.co'
    # end


    def call(env)
      base_url = 'https://verndari.io'
      email = Verndari.configuration.email
      host = Verndari.configuration.host

      begin
        request = Rack::Request.new(env)

        res = Faraday.post "#{base_url}/api/keys/validate", { email: email, domain: host, data: request.params.to_json }
        json_body = JSON.parse(res.body)

        if json_body['is_valid'].eql?(true)
          status, headers, response = @app.call(env)
          return [status, headers, response]
        else
          return [ 500, {}, ["Internal Server Error\n"]]
        end
      rescue
        return [status, headers, response]
      end


    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
verndari-0.2.20 lib/verndari/congress.rb