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.
14 15 16 17 |
# File 'lib/inertia_rails/middleware.rb', line 14 def initialize(app, env) @app = app @env = env end |
Instance Method Details
#response ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/inertia_rails/middleware.rb', line 19 def response copy_xsrf_to_csrf! status, headers, body = @app.call(@env) request = ActionDispatch::Request.new(@env) # Inertia errors are added to the session via redirect_to unless (status) request.session.delete(:inertia_errors) request.session.delete(:inertia_clear_history) end status = 303 if inertia_non_post_redirect?(status) stale_inertia_get? ? force_refresh(request) : [status, headers, body] end |