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.
13 14 15 16 |
# File 'lib/inertia_rails/middleware.rb', line 13 def initialize(app, env) @app = app @env = env end |
Instance Method Details
#response ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/inertia_rails/middleware.rb', line 18 def response status, headers, body = @app.call(@env) request = ActionDispatch::Request.new(@env) ::InertiaRails.reset! # 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 |