1
0
mirror of https://github.com/kataras/iris.git synced 2026-01-23 11:56:00 +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

@@ -600,7 +600,8 @@ New Package-level Variables:
New Context Methods:
- `Context.ReadParams(ptr interface{}) error` to bind dynamic path parameters. [Example](https://github.com/kataras/iris/blob/master/_examples/request-body/read-params/main.go).
- `Context.ReadHeaders(ptr interface{}) error` binds request headers to "ptr". [Example](https://github.com/kataras/iris/blob/master/_examples/request-body/read-headers/main.go).
- `Context.ReadParams(ptr interface{}) error` binds dynamic path parameters to "ptr". [Example](https://github.com/kataras/iris/blob/master/_examples/request-body/read-params/main.go).
- `Context.SaveFormFile(fh *multipart.FileHeader, dest string) (int64, error)` previously unexported. Accepts a result file of `Context.FormFile` and saves it to the disk.
- `Context.URLParamSlice(name string) []string` is a a shortcut of `ctx.Request().URL.Query()[name]`. Like `URLParam` but it returns all values as a string slice instead of a single string separated by commas.
- `Context.PostValueMany(name string) (string, error)` returns the post data of a given key. The returned value is a single string separated by commas on multiple values. It also reports whether the form was empty or when the "name" does not exist or whether the available values are empty. It strips any empty key-values from the slice before return. See `ErrEmptyForm`, `ErrNotFound` and `ErrEmptyFormField` respectfully. The `PostValueInt`, `PostValueInt64`, `PostValueFloat64` and `PostValueBool` now respect the above errors too (the `PostValues` method now returns a second output argument of `error` too, see breaking changes below).