2022-05-28 05:42:28 +03:00
|
|
|
// Copyright 2017 Manu Martinez-Almeida. All rights reserved.
|
2017-07-19 10:50:05 +03: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 15:12:22 +03:00
|
|
|
import "net/http"
|
2017-07-19 10:50:05 +03:00
|
|
|
|
|
|
|
type queryBinding struct{}
|
|
|
|
|
|
|
|
func (queryBinding) Name() string {
|
|
|
|
return "query"
|
|
|
|
}
|
|
|
|
|
2022-03-21 04:43:17 +03:00
|
|
|
func (queryBinding) Bind(req *http.Request, obj any) error {
|
2017-07-19 10:50:05 +03:00
|
|
|
values := req.URL.Query()
|
|
|
|
if err := mapForm(obj, values); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
return validate(obj)
|
|
|
|
}
|