Class: Pechkin::App

Inherits:
Object
  • Object
show all
Defined in:
lib/pechkin/app.rb

Overview

Rack application to handle requests

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#handlerObject

Returns the value of attribute handler.



43
44
45
# File 'lib/pechkin/app.rb', line 43

def handler
  @handler
end

Instance Method Details

#call(env) ⇒ Object



45
46
47
48
49
50
# File 'lib/pechkin/app.rb', line 45

def call(env)
  RequestHandler.new(handler, env).handle
rescue StandardError => e
  body = { status: 'error', reason: e.message }.to_json
  ['503', { 'Content-Type' => 'application/json' }, [body]]
end