-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
rename context.Query to context.Form #16562
Conversation
Why?
Why add layers on top of native Go APIs that are already simple, easy to use, well-understood, well-documented, and that have predictable (and desirable) behavior? Wouldn't it be better to go the opposite direction and remove the legacy Gogs/Macaron/Gitea code in favor of cleaner, simpler, native Go code? I would much prefer to use the standard Go and Chi approaches: str := r.URL.Query().Get(k)
val := r.FormValue(k)
ctx := r.Context()
data := r.Context().Value("data").(*Data)
tpl := data["something"] I also understand having a few convenience functions or perhaps an object to hold r := ctx.Req
str := r.URL.Query().Get(k)
val := r.FormValue(k)
tpl := ctx.Data["something"] But the idea of adding new APIs that need new documentation around APIs that already work exactly as expected... makes me sad. |
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.
I thought it will already work as named ?!?
These simple wrap functions will help to convert string to int, bool or others. i.e. |
Like @coolaj86 said QueryXXX should wrap |
Codecov Report
@@ Coverage Diff @@
## main #16562 +/- ##
==========================================
- Coverage 45.41% 45.40% -0.01%
==========================================
Files 749 749
Lines 84457 84457
==========================================
- Hits 38353 38348 -5
- Misses 39928 39932 +4
- Partials 6176 6177 +1
Continue to review full report at Codecov.
|
This renamed funct. Are used in api a lot so we should migrate them all to use query directly. What porpuse does this form functions do have beside getting query values?!? |
Instead of renaming i propose to refactor it to do what the name sound like or just delete it |
I agree we need use QueryX for those GET requests, but to make review easier, I would like to make it as two steps. This is the first step to rename QueryX to FormX, next step to add QueryX back and move functions on GET requests to use QueryX . |
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.
one step at a time ...
The name
Query
on context derived from macaron is confusing because it should only get query parameters from URL query.This PR renames
Query
toForm
as the first step. Next step, we need add the realQuery
methods and change some routers' revocations.