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
✨ feature: add AllParams method #1853
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -833,6 +833,17 @@ func (c *Ctx) Params(key string, defaultValue ...string) string { | |
return defaultString("", defaultValue) | ||
} | ||
|
||
// Params is used to get all route parameters. | ||
// Using Params method to get params. | ||
func (c *Ctx) AllParams() map[string]string { | ||
params := make(map[string]string, len(c.route.Params)) | ||
for _, param := range c.route.Params { | ||
params[param] = c.Params(param) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. please adjust it based on suggestion when having many params There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'll look at tomorrow. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I couldn't understand why to need make it []string instead of string. Can you explain me? |
||
} | ||
|
||
return params | ||
} | ||
|
||
// ParamsInt is used to get an integer from the route parameters | ||
// it defaults to zero if the parameter is not found or if the | ||
// parameter cannot be converted to an integer | ||
|
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.
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.
there is no list, always only one parameter value for one parameter key