mirror of
https://github.com/zitadel/zitadel.git
synced 2025-08-11 21:07:31 +00:00
feat: add some api packages
This commit is contained in:
28
internal/api/http/parser.go
Normal file
28
internal/api/http/parser.go
Normal file
@@ -0,0 +1,28 @@
|
||||
package http
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/gorilla/schema"
|
||||
|
||||
"github.com/caos/zitadel/internal/errors"
|
||||
)
|
||||
|
||||
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", "error parsing http form")
|
||||
}
|
||||
|
||||
return p.decoder.Decode(data, r.Form)
|
||||
}
|
Reference in New Issue
Block a user