Class: Jets::PublicController
- Inherits:
-
Controller::Base
- Object
- Lambda::Functions
- Controller::Base
- Jets::PublicController
- Defined in:
- lib/jets/internal/app/controllers/jets/public_controller.rb
Constant Summary
Constants included from Router::Helpers::CoreHelper
Router::Helpers::CoreHelper::CONTROLLER_DELEGATES
Instance Attribute Summary
Attributes inherited from Controller::Base
Attributes inherited from Lambda::Functions
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, process, #process!
Methods included from Controller::Rendering
#actual_host, #add_stage_name, #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
Methods included from Router::Helpers::CoreHelper
Methods included from Controller::ForgeryProtection
Methods included from Controller::Cookies
Methods inherited from Lambda::Functions
inherited, #initialize, output_keys, subclasses
Methods included from Lambda::Dsl
Constructor Details
This class inherits a constructor from Jets::Controller::Base
Instance Method Details
#show ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/jets/internal/app/controllers/jets/public_controller.rb', line 8 def show catchall = params[:catchall].blank? ? 'index.html' : params[:catchall] public_path = Jets.root + "public" catchall_path = "#{public_path}/#{catchall}" if File.exist?(catchall_path) content_type = Rack::Mime.mime_type(File.extname(catchall_path)) binary = !MiniMime.lookup_by_filename(catchall_path).content_type.include?("text") # For binary support to work, the client also has to send the right Accept header. # And the media type has been to added to api gateway. # Cavaet: adding * to as the media type breaks regular form submission. # All form submission gets treated as binary. if binary encoded_content = Base64.encode64(IO.read(catchall_path)) render plain: encoded_content, content_type: content_type, base64: true else render file: catchall_path, content_type: content_type end else render file: "#{public_path}/404", status: 404 end end |