feat: add Go 1.27 generic parsing methods to Context - #3069
Conversation
|
relates to #3066 |
aldas
left a comment
There was a problem hiding this comment.
looks ok, but could you use table based tests
Do you have any other suggestions for naming this function? I’m not entirely sure whether the current name is appropriate. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #3069 +/- ##
==========================================
+ Coverage 93.34% 95.72% +2.37%
==========================================
Files 43 45 +2
Lines 4735 4045 -690
==========================================
- Hits 4420 3872 -548
+ Misses 192 173 -19
+ Partials 123 0 -123 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Thanks for the suggestion. I agree that the The main reason for adding it is backward compatibility. Reusing those names would require replacing or renaming the existing methods, breaking calls such as: value := c.QueryParam("page")
values := c.QueryParams()The value := c.QueryParam("page")
page, err := c.ParseQueryParam[int]("page")Although the path parameter methods do not have the same direct conflict—the existing raw accessor is named The prefix also makes the type conversion and possible parsing error explicit. Meanwhile, the package-level generic functions can keep the shorter names: page, err := echo.QueryParam[int](c, "page")I am open to another non-conflicting naming convention, but removing the prefix entirely would require a breaking API change. |
|
allright, I was just reading this on github web gui and did not actually checked what methods existed. I am sorry for wasting your time. I will do proper review tonight. |
Summary
This PR adds Go 1.27 generic parameter parsing methods to
Context.The new methods support:
Orvariantstime.TimelayoutsGoDoc comments and test coverage are included for all new methods.
Examples
Testing
The added tests cover:
All packages have also been verified to compile with Go 1.27.
Additional context
This is my first contribution to the Echo project.
I used AI-assisted development while working on this change. I have reviewed the generated changes and verified them with the relevant tests.
If there are any concerns about the API design, naming, implementation, or test coverage, I would be happy to discuss them and make the necessary adjustments.