Class: InertiaRails::Middleware::InertiaRailsRequest
- Inherits:
-
Object
- Object
- InertiaRails::Middleware::InertiaRailsRequest
- Defined in:
- lib/inertia_rails/middleware.rb
Instance Method Summary collapse
-
#initialize(app, env) ⇒ InertiaRailsRequest
constructor
A new instance of InertiaRailsRequest.
- #response ⇒ Object
Constructor Details
#initialize(app, env) ⇒ InertiaRailsRequest
Returns a new instance of InertiaRailsRequest.
15 16 17 18 |
# File 'lib/inertia_rails/middleware.rb', line 15 def initialize(app, env) @app = app @env = env end |
Instance Method Details
#response ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/inertia_rails/middleware.rb', line 20 def response status, headers, body = @app.call(@env) request = ActionDispatch::Request.new(@env) # Inertia errors are added to the session via redirect_to request.session.delete(:inertia_errors) unless keep_inertia_errors?(status) status = 303 if inertia_non_post_redirect?(status) stale_inertia_get? ? force_refresh(request) : [status, headers, body] end |