1
0
mirror of https://github.com/kataras/iris.git synced 2025-12-24 05:17:03 +00:00

add Context.ReadHeaders

This commit is contained in:
Gerasimos (Makis) Maropoulos
2020-08-31 21:28:13 +03:00
parent 29084d062e
commit dbeb7bfb73
6 changed files with 103 additions and 3 deletions

View File

@@ -2289,6 +2289,18 @@ func (ctx *Context) ReadQuery(ptr interface{}) error {
return ctx.app.Validate(ptr)
}
// ReadHeaders binds request headers to "ptr". The struct field tag is "header".
//
// Example: https://github.com/kataras/iris/blob/master/_examples/request-body/read-headers/main.go
func (ctx *Context) ReadHeaders(ptr interface{}) error {
err := schema.DecodeHeaders(ctx.request.Header, ptr)
if err != nil {
return err
}
return ctx.app.Validate(ptr)
}
// ReadParams binds URI Dynamic Path Parameters to "ptr". The struct field tag is "param".
//
// Example: https://github.com/kataras/iris/blob/master/_examples/request-body/read-params/main.go