1
0
mirror of https://github.com/kataras/iris.git synced 2026-01-10 21:45:57 +00:00

Add DisableBodyConsumptionOnUnmarshal configuration field as discussed on [chat](https://kataras.rocket.chat/channel/iris). Read HISTORY.md

This commit is contained in:
Gerasimos (Makis) Maropoulos
2017-01-30 12:35:43 +02:00
parent a563b37ba1
commit 2a911a450c
6 changed files with 102 additions and 36 deletions

View File

@@ -548,6 +548,12 @@ func (ctx *Context) UnmarshalBody(v interface{}, unmarshaler Unmarshaler) error
return err
}
if ctx.framework.Config.DisableBodyConsumptionOnUnmarshal {
// * remember, Request.Body has no Bytes(), we have to consume them first
// and after re-set them to the body, this is the only solution.
ctx.Request.Body = ioutil.NopCloser(bytes.NewBuffer(rawData))
}
// check if the v contains its own decode
// in this case the v should be a pointer also,
// but this is up to the user's custom Decode implementation*