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

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

Defined Under Namespace

Classes: Request

Constant Summary

Constants included from TruncatedInspect

TruncatedInspect::MAX_LENGTH

Instance Attribute Summary

Attributes inherited from Foobara::CommandConnectors::Http

#prefix

Attributes inherited from Foobara::CommandConnector

#authenticator, #capture_unknown_error, #command_registry

Instance Method Summary collapse

Methods inherited from Foobara::CommandConnectors::Http

#headers_for, #initialize, #mutate_response, #request_to_command, #run, #set_response_status

Methods included from TruncatedInspect

#inspect, truncating

Methods inherited from Foobara::CommandConnector

#all_exposed_commands, allowed_rules_to_register, #authenticate, authenticator_registry, #build_command, #build_request, #build_response, #connect, #connect_delayed, #delayed_connections, find_builtin_command_class, #find_builtin_command_class, #foobara_manifest, #initialize, #lookup_command, #mutate_response, #normalize_manifest, #patch_up_broken_parents_for_errors_with_missing_command_parents, #process_delayed_connections, register_allowed_rule, register_authenticator, #request_to_command, #request_to_response, #run, #run_command, #run_request, #serialize_response_body, #set_response_body, #set_response_status, to_authenticator, #transform_command_class, #type_from_name

Constructor Details

This class inherits a constructor from Foobara::CommandConnectors::Http

Instance Method Details

#call(env) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'foobara-rack-connector-0.0.10/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 'foobara-rack-connector-0.0.10/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