1
0
mirror of https://github.com/kataras/iris.git synced 2026-03-04 23:46:06 +00:00

add Context.ReadParams method

This commit is contained in:
Gerasimos (Makis) Maropoulos
2020-08-31 20:30:01 +03:00
parent 2f51845138
commit 477f5e6f9b
7 changed files with 91 additions and 11 deletions

View File

@@ -600,6 +600,7 @@ 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.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).