Method: WSDSL#controller_dispatch

Defined in:
lib/wsdsl.rb

#controller_dispatch(app) ⇒ #to_s

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Offers a way to dispatch the service at runtime Basically, it dispatches the request to the defined controller/action The full request cycle looks like that: client -> webserver -> rack -> env -> [service dispatcher] -> controller action -> rack -> webserver -> client

Parameters:

  • app (Object)

    Reference object such as a Sinatra::Application to be passed to the controller.

Returns:

  • (#to_s)

    The response from the controller action

Since:

  • 0.0.3



195
196
197
198
199
200
201
202
203
204
205
206
207
# File 'lib/wsdsl.rb', line 195

def controller_dispatch(app)
  unless @controller
    klass = @controller_name.split("::")
    begin
      @controller = klass.inject(Object) { |const,k| const.const_get(k) }
    rescue NameError => e
      raise "The #{@controller_name} class was not found"
    end
  end
  # We are passing the service object to the controller so the
  # param verification could be done when the controller gets initialized.
  @controller.new(app, self).send(@action)
end