Sha256: f787daa999914e636345ab3a7be6331c2a01d61eef85763de2240d3c185bf020

Contents?: true

Size: 603 Bytes

Versions: 3

Compression:

Stored size: 603 Bytes

Contents

require 'rack/lint'
require 'json'
class ErrorChecker
  def initialize(app)
    @app = app
  end

  def call(env)
    begin
      return @app.call(env)
    rescue Exception => e
      [
        500,
        { "X-Exception" => e.message, "X-Exception-Class" => e.class.to_s },
        [JSON.dump({"exception" => e.message})]
      ]
    end
  end
end

class ServerLint < Rack::Lint
  def call(env)
    assert("No env given") { env }
    check_env env

    @app.call(env)
  end
end

use ServerLint
use ErrorChecker
app = lambda { |env| [200, { "X-Header" => "Works" }, [JSON.dump({r:'Hello'})]] }
run app

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
jubilee-3.0.0.beta2-java test/apps/checker.ru
jubilee-2.1.0.rc1-java test/apps/checker.ru
jubilee-2.1.0.beta-java test/apps/checker.ru