-
-
Notifications
You must be signed in to change notification settings - Fork 225
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Inertia Middleware: A better home for user-provided defaults. #161
Conversation
Thanks so much for working on this @claudiodekker! So, I don't really understand the need for the trait here. I think it would be nice to just use regular inheritance instead. I've hacked on this a little tonight, and got it working the way I was hoping. Please find both a proposed new Inertia adapter middleware below, and an example user-land implementation (based on Ping CRM). Adapter:
|
Hey @reinink 👋 , Yeah, that was actually the first thing I tried, but for some reason it wouldn't work? I got into the situation where it would call Anyway, I probably missed something, because I used what you suggested, and it worked just fine this time around 🤔 |
Co-authored-by: Jonathan Reinink <[email protected]>
Co-authored-by: Jonathan Reinink <[email protected]>
Co-authored-by: Jonathan Reinink <[email protected]>
Co-authored-by: Jonathan Reinink <[email protected]>
Co-authored-by: Jonathan Reinink <[email protected]>
Co-authored-by: Jonathan Reinink <[email protected]>
Co-authored-by: Jonathan Reinink <[email protected]>
Co-authored-by: Jonathan Reinink <[email protected]>
Co-authored-by: Jonathan Reinink <[email protected]>
Co-authored-by: Jonathan Reinink <[email protected]>
This makes editor autocompletion more friendly, as before there would be two classes that would be called Inertia otherwise.
This PR introduces a new way of setting up and sharing application defaults with Inertia.
Up until this point, we've always used (and recommended) the
AppServiceProvider
as the place to do this, but doing so has a few negative impacts, most important one being that Inertia gets bootstrapped even when it does not have to (e.g. when running inside the Console).By using Middleware for this instead, we not only solve this problem, but it becomes possible to provide different defaults for each route (group), as you're free to (re)configure these middleware as you see fit!
To use:
php artisan inertia:middleware
to generate a newHandleInertiaRequests
middleware.\App\Http\Middleware\HandleInertiaRequests::class
to your application's Middleware stack.Example implementation: https://github.com/inertiajs/pingcrm/pull/88/files