Class: Jets::MountController

Inherits:
BareController show all
Defined in:
lib/jets/internal/app/controllers/jets/mount_controller.rb

Overview

routes mount support

Constant Summary

Constants included from Router::Helpers::CoreHelper

Router::Helpers::CoreHelper::CONTROLLER_DELEGATES

Instance Attribute Summary

Attributes inherited from Controller::Base

#request, #response, #session

Attributes inherited from Lambda::Functions

#context, #event, #meth

Instance Method Summary collapse

Methods inherited from Controller::Base

#action_name, #controller_name, #controller_paths, #dispatch!, #event_log, helper_method, #initialize, internal, #json_dump, #log_finish, #log_start, #method_override!, process, #process!, #processing_log

Methods included from Controller::Rendering

#actual_host, #add_stage, #adjust_content_type!, #default_layout, #ensure_render, #managed_options, #normalize_options, #render, #url_for

Methods included from Controller::Redirection

#ensure_protocol, #redirect_back, #redirect_to

Methods included from Controller::Params

#body_params, #filtered_parameters, #params, #path_params, #query_params, #request_params, #unescape_recursively

Methods included from Router::Helpers::NamedRoutesHelper

clear!

Methods included from Router::Helpers::CoreHelper

#polymorphic_path

Methods included from Controller::ForgeryProtection

#verify_authenticity_token

Methods included from Controller::Cookies

#cookies

Methods inherited from Lambda::Functions

inherited, #initialize, output_keys, subclasses

Methods included from Lambda::Dsl

#lambda_functions

Constructor Details

This class inherits a constructor from Jets::Controller::Base

Instance Method Details

#callObject



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/jets/internal/app/controllers/jets/mount_controller.rb', line 3

def call
  route = find_route
  # On Lambda, the route should always be found so this check on lambda is not needed.
  # But this is useful when we're testing locally with the shim directly.
  unless route
    render json: {status: "route not found"}, status: 404
    return
  end

  # The reason we look up the route is because it contains mounted class info
  mount_class = route.mount_class # IE: RackApp
  env = build_env(route.path)

  status, headers, io = mount_class.call(env)
  body = read_body(io)
  render(
    status: status,
    headers: headers,
    body: body,
  )
end