您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

25 行
472B

  1. package form
  2. import (
  3. "net/http"
  4. . "github.com/gorilla/schema"
  5. )
  6. var schema = NewDecoder()
  7. type Validator interface {
  8. Validate() error
  9. }
  10. // Parse parsed the raw query from the URL and updates request.Form,
  11. // decode the from to the given struct with Validator implemented.
  12. func parse(r *http.Request, form Validator) (err error) {
  13. if err = r.ParseForm(); err == nil {
  14. if err = schema.Decode(form, r.Form); err == nil {
  15. err = form.Validate()
  16. }
  17. }
  18. return
  19. }