-
-
Notifications
You must be signed in to change notification settings - Fork 24
Add options to control method failure handling in the Router middleware #266
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
base: master
Are you sure you want to change the base?
Add options to control method failure handling in the Router middleware #266
Conversation
|
As noted in #270 (comment), point 1 (default handler) is better to be done as in #270. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #266 +/- ##
=============================================
- Coverage 97.40% 73.69% -23.71%
- Complexity 181 185 +4
=============================================
Files 16 18 +2
Lines 577 574 -3
=============================================
- Hits 562 423 -139
- Misses 15 151 +136 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
rename handler to action
|
Version with 'Handler' renamed to the 'Action'. |
|
I'll update readme |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds configurable method failure handling to the Router middleware, allowing users to customize responses for HTTP method mismatches (405 errors) and OPTIONS requests. Previously, the Router middleware had hardcoded behavior for these scenarios.
- Introduces
MethodFailureHandlerInterfaceandMethodFailureHandlerfor customizable method failure responses - Modifies Router middleware to accept an optional method failure handler parameter
- Updates configuration to provide default method failure handler via DI container
Reviewed Changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| src/MethodFailureHandlerInterface.php | Defines interface for handling method failure responses |
| src/MethodFailureHandler.php | Default implementation that preserves existing 405/204 response behavior |
| src/Middleware/Router.php | Updates constructor to accept optional method failure handler and removes hardcoded response logic |
| tests/Middleware/MethodFailureHandlerTest.php | Test coverage for the default method failure handler |
| tests/Middleware/RouterTest.php | Updates router tests to cover both with and without method failure handler scenarios |
| config/di-web.php | New DI configuration file providing default method failure handler binding |
| README.md | Documentation updates explaining the new method failure handling feature |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
prev #250