Sha256: cf03ac426eb69935fd7d46aa6adf25b8dc4d1ae0cc5403453b8a40fe64cc1eaa

Contents?: true

Size: 578 Bytes

Versions: 1

Compression:

Stored size: 578 Bytes

Contents

module ExceptionsApp
  class SimpleResponse
    
    def initialize(headers = nil)
      @headers = headers
    end

    def call(env)
      status = env["PATH_INFO"][1..-1]
      @headers ||= {}
      statics_path = "#{ExceptionsApp.config.statics_path}/#{status}.html"

      if File.exists?(statics_path)
        render(status, File.read(statics_path))
      else
        [status, @headers.merge!({"X-Cascade" => "pass"}), []]
      end
    end

    private
    
    def render(status, body)
      [status, {'Content-Length' => body.bytesize.to_s}, [body]]
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
exceptions_app-0.0.1 lib/exceptions_app/simple_response.rb