另客网go项目公用的代码库

query.go 469B

12345678910111213141516171819202122
  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. }