Class: RailsTwirp::Base

Inherits:
Metal
  • Object
show all
Includes:
AbstractController::AssetPaths, AbstractController::Callbacks, AbstractController::Rendering, ActionController::Helpers, ActionView::Rendering, Errors, ExceptionHandling, ImplicitRender, Instrumentation, RenderPb, Rescue, UrlFor
Defined in:
lib/rails_twirp/base.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from ExceptionHandling

#process_action

Methods included from Instrumentation

#process_action

Methods included from ImplicitRender

#default_render

Methods included from Errors

#error

Methods included from RenderPb

#_render_to_body_with_pb, #render_to_body

Methods included from UrlFor

#url_options

Methods inherited from Metal

controller_name, #controller_name

Constructor Details

#initializeBase

Returns a new instance of Base.



49
50
51
52
53
54
# File 'lib/rails_twirp/base.rb', line 49

def initialize
  @_request = nil
  @_env = nil
  @_response_class = nil
  super
end

Class Method Details

.dispatch(action, request, response_class, rpc_name, env = {}) ⇒ Object



73
74
75
# File 'lib/rails_twirp/base.rb', line 73

def self.dispatch(action, request, response_class, rpc_name, env = {})
  new.dispatch(action, request, response_class, rpc_name, env)
end

Instance Method Details

#details_for_lookupObject

Used by the template renderer to figure out which template to use



78
79
80
# File 'lib/rails_twirp/base.rb', line 78

def details_for_lookup
  {formats: [:pb], handlers: [:pbbuilder]}
end

#dispatch(action, request, response_class, rpc_name, env = {}) ⇒ Object



60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/rails_twirp/base.rb', line 60

def dispatch(action, request, response_class, rpc_name, env = {})
  self.request = request
  self.env = env
  self.response_class = response_class
  self.rpc_name = rpc_name

  http_request.controller_instance = self

  process(action)

  response_body
end

#http_requestObject



56
57
58
# File 'lib/rails_twirp/base.rb', line 56

def http_request
  @_http_request ||= ActionDispatch::Request.new(env[:rack_env])
end

#requestObject

:attr_reader: request

The ActionDispatch::Request instance for the current request.



45
# File 'lib/rails_twirp/base.rb', line 45

attr_internal :request