mirror of
https://github.com/kataras/iris.git
synced 2025-12-24 05:17:03 +00:00
context#ReadForm can skip unkown fields by iris/context.IsErrPath(err), fixes: https://github.com/kataras/iris/issues/1157
Former-commit-id: 5cc8e5a9d58071591154e988262b547653c34e36
This commit is contained in:
@@ -2286,9 +2286,12 @@ func (ctx *context) ReadXML(xmlObject interface{}) error {
|
||||
return ctx.UnmarshalBody(xmlObject, UnmarshalerFunc(xml.Unmarshal))
|
||||
}
|
||||
|
||||
var (
|
||||
errReadBody = errors.New("while trying to read %s from the request body. Trace %s")
|
||||
)
|
||||
// IsErrPath can be used at `context#ReadForm`.
|
||||
// It reports whether the incoming error is type of `formbinder.ErrPath`,
|
||||
// which can be ignored when server allows unknown post values to be sent by the client.
|
||||
//
|
||||
// A shortcut for the `formbinder#IsErrPath`.
|
||||
var IsErrPath = formbinder.IsErrPath
|
||||
|
||||
// ReadForm binds the formObject with the form data
|
||||
// it supports any kind of type, including custom structs.
|
||||
@@ -2304,7 +2307,7 @@ func (ctx *context) ReadForm(formObject interface{}) error {
|
||||
// or dec := formbinder.NewDecoder(&formbinder.DecoderOptions{TagName: "form"})
|
||||
// somewhere at the app level. I did change the tagName to "form"
|
||||
// inside its source code, so it's not needed for now.
|
||||
return errReadBody.With(formbinder.Decode(values, formObject))
|
||||
return formbinder.Decode(values, formObject)
|
||||
}
|
||||
|
||||
// +------------------------------------------------------------+
|
||||
|
||||
Reference in New Issue
Block a user