Skip to content
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

Wrong query binding struct tag #3235

Closed
illiafox opened this issue Jul 10, 2022 · 3 comments
Closed

Wrong query binding struct tag #3235

illiafox opened this issue Jul 10, 2022 · 3 comments

Comments

@illiafox
Copy link
Contributor

gin/binding/query.go

Lines 15 to 21 in b57163a

func (queryBinding) Bind(req *http.Request, obj any) error {
values := req.URL.Query()
if err := mapForm(obj, values); err != nil {
return err
}
return validate(obj)
}

mapForm searches form struct tag, not query

Fixed version:

func (q queryBinding) Bind(req *http.Request, obj any) error {
	values := req.URL.Query()
	if err := mapFormByTag(obj, values, q.Name() ); err != nil {
		return err
	}
	return validate(obj)
}
This was referenced Jul 10, 2022
@appleboy
Copy link
Member

fixed in #3236 @illiafox Thanks.

@appleboy
Copy link
Member

@illiafox Please open the new PR to fix the testing. #3236 can't pass the testing

@appleboy appleboy reopened this Mar 21, 2024
@illiafox
Copy link
Contributor Author

I guess the issue can be closed as the query tag is not used anywhere

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants