zitadel/internal/form/parser.go
Fabi 2c97794538
feat: login errors (#204)
* feat: nice error messages

* feat: nice error messages

* fix: add project type

* fix: message ids

* handle error messages in login

* add some better error messages

* fix: better error messages on login

* fix: better error messages on login

* fix: add internal errors

* fix: tests
2020-06-11 13:22:24 +02:00

28 lines
481 B
Go

package form
import (
"github.com/caos/zitadel/internal/errors"
"net/http"
"github.com/gorilla/schema"
)
type Parser struct {
decoder *schema.Decoder
}
func NewParser() *Parser {
d := schema.NewDecoder()
d.IgnoreUnknownKeys(true)
return &Parser{d}
}
func (p *Parser) Parse(r *http.Request, data interface{}) error {
err := r.ParseForm()
if err != nil {
return errors.ThrowInternal(err, "FORM-lCC9zI", "Errors.Internal")
}
return p.decoder.Decode(data, r.Form)
}