fix panic when both handler and middlewares are nil#2500
Open
ttrasn wants to merge 1 commit intolabstack:masterfrom
Open
fix panic when both handler and middlewares are nil#2500ttrasn wants to merge 1 commit intolabstack:masterfrom
ttrasn wants to merge 1 commit intolabstack:masterfrom
Conversation
Contributor
|
could you explain why this case should act as no-op instead of panic? most of the cases I think providing nil for these value should be considered as something going very wrong. |
Author
|
Showing a 404 error is better than showing a panic error. I don't think it's possible for someone to intentionally not send the handler and only set the route. |
Author
|
Hi @aldas, could you please check this PR? |
Contributor
|
I really do not want to accept this behavior. Probably just doing this is better if handler == nil {
panic("can not add route with nil handler")
}to fail fast and before even the server is started. Adding route without handler is something deeply wrong in developers code. |
ttrasn
commented
Sep 20, 2023
| return true | ||
| } | ||
| } | ||
| return false |
Author
There was a problem hiding this comment.
You mean when both of them were nil ?
Suggested change
| return false | |
| panic("can not add route with nil handler and middlewares") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.