2022-05-28 02:42:28 +00:00
|
|
|
// Copyright 2017 Manu Martinez-Almeida. All rights reserved.
|
2017-07-19 07:50:05 +00:00
|
|
|
// Use of this source code is governed by a MIT style
|
|
|
|
// license that can be found in the LICENSE file.
|
|
|
|
|
|
|
|
package binding
|
|
|
|
|
2017-10-29 12:12:22 +00:00
|
|
|
import "net/http"
|
2017-07-19 07:50:05 +00:00
|
|
|
|
|
|
|
type queryBinding struct{}
|
|
|
|
|
|
|
|
func (queryBinding) Name() string {
|
|
|
|
return "query"
|
|
|
|
}
|
|
|
|
|
2022-03-21 01:43:17 +00:00
|
|
|
func (queryBinding) Bind(req *http.Request, obj any) error {
|
2017-07-19 07:50:05 +00:00
|
|
|
values := req.URL.Query()
|
|
|
|
if err := mapForm(obj, values); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
return validate(obj)
|
|
|
|
}
|