Class: Tom::GoliathAPI

Inherits:
Goliath::API
  • Object
show all
Defined in:
lib/goliath_api.rb

Overview

WE HAZ ALL TEH GOLIATH REQUESTS AND FORWARDETH THEM TO DEH DISPATCHERETH.

We have to see if this is the right way to do it when it comes to parallel stuff and so on…

Instance Method Summary collapse

Instance Method Details

#handle_exception(e, env) ⇒ Object

Hardcoded JSON stacktrace stuff for now…



23
24
25
26
27
28
29
30
31
# File 'lib/goliath_api.rb', line 23

def handle_exception(e, env)
  trace = e.backtrace.join "\n"
  Tom::Log.logger.info e
  Tom::Log.logger.info trace
  [500, {}, {error: e,
    stacktrace: trace,
    url:        env["REQUEST_URI"]
  }.to_json]
end

#response(env) ⇒ Object

Forwards env to Dispatcher.dispatch, look there.

Parameters:

  • env (Hash)

    Rack env



14
15
16
17
18
19
20
# File 'lib/goliath_api.rb', line 14

def response(env)
  begin
    Tom::Dispatcher.dispatch(env)
  rescue => e
    handle_exception e, env
  end
end