-
Notifications
You must be signed in to change notification settings - Fork 11k
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
[8.x] Allows Stringable objects as middleware. #39439
[8.x] Allows Stringable objects as middleware. #39439
Conversation
Does this work for route groups, etc? Route::middleware()->group(fn); |
Yes. I added a new test to be 200% sure. |
Test stalled (HUGE THANKS WINDOWS). Can someone make a re-run? |
I may need to revert this already @DarkGhostHunter This simple test doesn't even work locally: |
What does the stack trace says? Weird since supposedly the value is casted as a string on ingress. If it's an array, it will do it for each member. |
Try it in your own application so we don't have to debug over GH issues. |
Asap.
Italo Baeza C.
… El 02-11-2021, a la(s) 12:32, Taylor Otwell ***@***.***> escribió:
Try it in your own application so we don't have to debug over GH issues.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
Got it. Forgot to add it to the Adding a PR to fix this... |
Fixed in #39449 |
framework/src/Illuminate/Routing/RouteRegistrar.php Lines 108 to 112 in dec9524
|
Docblock states only array or string are accepted. |
I ran into the same issue like @mingyoung using closure middleware. |
PHPDocs states only string or array are permitted.
Using Closures are not supported. There are not even tests for that.
Italo Baeza C.
… El 29-11-2021, a la(s) 09:35, Oliver Matla ***@***.***> escribió:
I ran into the same issue like @mingyoung using closure middleware.
I have no idea where I picked it up from, but it's obviously neither in the documentation nor in the tests... 🤷
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
I think that is, word by word, exactly what I wrote 😅 |
What?
You can use
Stringable
objects into middleware declaration. These will be transformed into a string automatically. Pretty much like aRule::exists()
works.Why?
This allows to use helpers for middleware that contain multiple parameters into one fluid sentence. Useful for packages that have middleware with a parameters that should be overridden per-route basis.
For example, the built-in
ThrottlesRequest
middleware which has 3 parameters. Using a Stringable-based helper, we can transform the declaration into something more understandable forwarding the call to the helper.Also works on Resource routes:
BC?