query.go 469 B

123456789101112131415161718192021
  1. // Copyright 2017 Manu Martinez-Almeida. All rights reserved.
  2. // Use of this source code is governed by a MIT style
  3. // license that can be found in the LICENSE file.
  4. package binding
  5. import "net/http"
  6. type queryBinding struct{}
  7. func (queryBinding) Name() string {
  8. return "query"
  9. }
  10. func (queryBinding) Bind(req *http.Request, obj interface{}) error {
  11. values := req.URL.Query()
  12. if err := mapForm(obj, values); err != nil {
  13. return err
  14. }
  15. return validate(obj)
  16. }