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"
|
|
|
|
}
|
|
|
|
|
2024-03-22 05:01:27 +03:00
|
|
|
func (queryBinding) Bind(req *http.Request, obj any) error {
|
2017-07-19 10:50:05 +03:00
|
|
|
values := req.URL.Query()
|
2024-03-22 05:01:27 +03:00
|
|
|
if err := mapForm(obj, values); err != nil {
|
2017-07-19 10:50:05 +03:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
return validate(obj)
|
|
|
|
}
|