-
Notifications
You must be signed in to change notification settings - Fork 427
feat(example): query module #4477
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
Conversation
🛠 PR Checks Summary🔴 Pending initial approval by a review team member, or review from tech-staff Manual Checks (for Reviewers):
Read More🤖 This bot helps streamline PR reviews by verifying automated checks and providing guidance for contributors and reviewers. ✅ Automated Checks (for Contributors):🟢 Maintainers must be able to edit this pull request (more info) ☑️ Contributor Actions:
☑️ Reviewer Actions:
📚 Resources:Debug
|
Seems like the CI failures dose not related with this PR. ignore this comment |
Codecov ReportAll modified and coverable lines are covered by tests ✅ 📢 Thoughts on this report? Let us know! |
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 left some suggestions, but implemtation looks good 👍
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.
LGTM 👍
remove: review/triage-pending
flag
Package query provides a simple way to handle queries in your realm. | ||
|
||
It includes helper functions to extract individual query parameters, convert the full query string into a map, | ||
and update one or more parameters in a URL. |
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.
would've been good to mention that is it specifically for queries, ie after ?
. we've three possible things in the URL:
pkgpath:renderpath{?queries , $gnowebparams}
This PR introduces a new query package that provides reusable helpers for working with URL query strings. It is designed to simplify parsing, updating, and reconstructing query parameters in a clean and generic way. This logic was originally embedded in the `blog` package (in gnolang#4324), but has now been extracted into its own utility package to promote reusability and separation of concerns. - ParseQueryParams(key, rawURL) → get a single query parameter value - ParseQueryMap(rawURL) → return all query parameters as a map[string]string - UpdateQuery(rawURL, key, value) → set or overwrite a single query param - UpdateQueryMulti(rawURL, map[string]string) → update multiple query params at once - DeleteQuery(rawURL, key) → remove a parameter from the query string *UPDATE* - `GetQueryValues` – Get all values for a given key. - `GetQueryFirstValue` – Get the first value for a given key. - `HasQueryKey` – Check if a key exists in the query. - `GetQueryValueFromURL` – Retrieve a query value from a raw URL. - `ParseQueryFirstValuesMap` – Parse a URL into a map of first values. - `UpdateQueryValue` – Set a single value for a key. - `UpdateQueryValues` – Set multiple values for a single key. - `UpdateQueryFirstValues` – Set single values for multiple keys. - `UpdateQueryAllValues` – Set multiple values for multiple keys. - `SetQueries` – Replace or add keys with single values. - `SetQueriesMulti` – Replace or add keys with multiple values. - `DeleteQuery` – Remove a specific key from the query. - `ResetQuery` – Remove all query parameters from the URL.
This PR introduces a new query package that provides reusable helpers for working with URL query strings. It is designed to simplify parsing, updating, and reconstructing query parameters in a clean and generic way.
This logic was originally embedded in the
blog
package (in #4324), but has now been extracted into its own utility package to promote reusability and separation of concerns.UPDATE
GetQueryValues
– Get all values for a given key.GetQueryFirstValue
– Get the first value for a given key.HasQueryKey
– Check if a key exists in the query.GetQueryValueFromURL
– Retrieve a query value from a raw URL.ParseQueryFirstValuesMap
– Parse a URL into a map of first values.UpdateQueryValue
– Set a single value for a key.UpdateQueryValues
– Set multiple values for a single key.UpdateQueryFirstValues
– Set single values for multiple keys.UpdateQueryAllValues
– Set multiple values for multiple keys.SetQueries
– Replace or add keys with single values.SetQueriesMulti
– Replace or add keys with multiple values.DeleteQuery
– Remove a specific key from the query.ResetQuery
– Remove all query parameters from the URL.