Skip to content

Wrong query binding struct tag #3235

@illiafox

Description

@illiafox

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)
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions