feat: add query parameter support to the reverse! macro - #642
Open
ChrisJr404 wants to merge 1 commit into
Open
Conversation
Path parameters are passed right after the view name, and query parameters can now be added after a semicolon. They get appended to the generated URL as a percent-encoded query string, so you don't have to build it by hand anymore.
ElijahAhianyo
left a comment
Contributor
There was a problem hiding this comment.
Thanks for the contribution @ChrisJr404! Aside the comment on replicating this for the reverse_redirect! macro, this looks good to me.
| #[macro_export] | ||
| macro_rules! reverse { | ||
| ($request:expr, $view_name:literal $(, $($key:ident = $value:expr),*)?) => {{ | ||
| ($request:expr, $view_name:literal |
Contributor
There was a problem hiding this comment.
would be nice to have this for reverse_redirect! as well
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.
Related issue or discussion
Closes #430
Description
Adds query parameter support to
reverse!. Path params are still passed right after the view name, and query params can now be added after a;, using the samekey = valuesyntax:They get appended as a percent-encoded query string (built with
form_urlencoded, which we already depend on). Values only need to implementToString, just like path params do. When no query params are given the URL is returned unchanged, so existingreverse!calls behave exactly as before.Type of change
Checklist
just test-all)just clippy)cargo fmt)