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.
12 13 14 15 |
# File 'lib/inertia_rails/middleware.rb', line 12 def initialize(app, env) @app = app @env = env end |
Instance Method Details
#response ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/inertia_rails/middleware.rb', line 17 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 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 |