Class: Foobara::CommandConnectors::Http::Rack

Inherits:
Foobara::CommandConnectors::Http show all
Defined in:
lib/foobara/command_connectors/http/rack.rb,
lib/foobara/command_connectors/http/puma_runner.rb,
lib/foobara/command_connectors/http/rack/request.rb,
lib/foobara/command_connectors/http/rack/response.rb

Defined Under Namespace

Classes: Request, Response

Instance Method Summary collapse

Instance Method Details

#call(env) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/foobara/command_connectors/http/rack.rb', line 5

def call(env)
  response = run(env)
  [response.status, response.headers, [response.body]]
rescue NotFoundError, InvalidContextError => e
  [404, {}, [e.message]]
rescue => e
  # :nocov:
  env["rack.errors"].puts e.to_s
  env["rack.errors"].puts e.backtrace

  raise e
  # :nocov:
end

#run_pumaObject

Just a convenience method for demos. In real projects use rackup/config.ru or set it all up with ‘foob g rack-connector`



7
8
9
10
11
12
13
14
# File 'lib/foobara/command_connectors/http/puma_runner.rb', line 7

def run_puma(**)
  # :nocov:
  require "puma"
  require "rack/handler/puma"

  ::Rack::Handler::Puma.run(self, **)
  # :nocov:
end