Sha256: 2aa98840d55f40d53cc307dea5718a407e49bc50415cdecc40d2fe57e9aae64f

Contents?: true

Size: 1.44 KB

Versions: 15

Compression:

Stored size: 1.44 KB

Contents

require 'rack/request'

module Jets::Controller
  class Request
    include Rack::Request::Helpers
    include Compat::Request
    include Compat::Params

    include ActionDispatch::Flash::RequestMethods
    include ActionDispatch::Http::Cache::Request
    include ActionDispatch::Http::MimeNegotiation
    include ActionDispatch::Http::FilterParameters # parameter_filter and filtered_parameters
    include ActionDispatch::Http::URL
    include ActionDispatch::RequestCookieMethods
    include ActionDispatch::ContentSecurityPolicy::Request
    include ActionDispatch::PermissionsPolicy::Request
    include Rack::Request::Env

    # since jets delegates parameter_filter from controller to request
    public :parameter_filter

    attr_reader :event, :env
    attr_accessor :routes
    def initialize(rack_env: nil, event: nil)
      @rack_env = rack_env
      @event = event
      @env = normalize_env
      super(@env) # Rack::Env module => super()
    end

    def normalize_env
      if @rack_env # already rack env
        @rack_env # rack_env is from Controller.action => lambda { |env| .. }
      else
        Jets::Controller::RackAdapter::Env.new(@event, {}).convert # convert to Rack env
      end
    end

    # When request hits the middleware Controller::RackAdapter::Middleware::Main endpoint
    # We updated env since it could had been mutated down the middleware stack
    # from Mimic to Main.
    def set_env!(env)
      @env = env
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
jets-5.0.13 lib/jets/controller/request.rb
jets-5.0.12 lib/jets/controller/request.rb
jets-5.0.11 lib/jets/controller/request.rb
jets-5.0.10 lib/jets/controller/request.rb
jets-5.0.9 lib/jets/controller/request.rb
jets-5.0.8 lib/jets/controller/request.rb
jets-5.0.7 lib/jets/controller/request.rb
jets-5.0.6 lib/jets/controller/request.rb
jets-5.0.5 lib/jets/controller/request.rb
jets-5.0.4 lib/jets/controller/request.rb
jets-5.0.3 lib/jets/controller/request.rb
jets-5.0.2 lib/jets/controller/request.rb
jets-5.0.1 lib/jets/controller/request.rb
jets-5.0.0 lib/jets/controller/request.rb
jets-5.0.0.beta1 lib/jets/controller/request.rb