get_form.go 514 B

1234567891011121314151617181920212223
  1. // Copyright 2014 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 getFormBinding struct{}
  7. func (_ getFormBinding) Name() string {
  8. return "get_form"
  9. }
  10. func (_ getFormBinding) Bind(req *http.Request, obj interface{}) error {
  11. if err := req.ParseForm(); err != nil {
  12. return err
  13. }
  14. if err := mapForm(obj, req.Form); err != nil {
  15. return err
  16. }
  17. return Validate(obj)
  18. }