query.go 474 B

1234567891011121314151617181920212223
  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 (
  6. "net/http"
  7. )
  8. type queryBinding struct{}
  9. func (queryBinding) Name() string {
  10. return "query"
  11. }
  12. func (queryBinding) Bind(req *http.Request, obj interface{}) error {
  13. values := req.URL.Query()
  14. if err := mapForm(obj, values); err != nil {
  15. return err
  16. }
  17. return validate(obj)
  18. }