Former-commit-id: ee1b625abe876cad8f0f2801c279da684b539fce
This commit is contained in:
Gerasimos (Makis) Maropoulos 2020-06-14 09:25:19 +03:00
parent 4afef007a4
commit 9c739969f0
2 changed files with 10 additions and 5 deletions

View File

@ -377,7 +377,9 @@ Other Improvements:
- New builtin [JWT](https://github.com/kataras/iris/tree/master/middleware/jwt) middleware based on [square/go-jose](https://github.com/square/go-jose) featured with optional encryption to set claims with sensitive data when necessary. - New builtin [JWT](https://github.com/kataras/iris/tree/master/middleware/jwt) middleware based on [square/go-jose](https://github.com/square/go-jose) featured with optional encryption to set claims with sensitive data when necessary.
- `Context.ReadForm` now can return an `iris.ErrEmptyForm` instead of `nil` when the new `Configuration.FireEmptyFormError` is true (or `iris.WithEmptyFormError`) on missing form body to read from. - New `iris.RouteOverlap` route registration rule. `Party.SetRegisterRule(iris.RouteOverlap)` to allow overlapping across multiple routes for the same request subdomain, method, path. See [1536#issuecomment-643719922](https://github.com/kataras/iris/issues/1536#issuecomment-643719922).
- `Context.ReadForm` now can return an `iris.ErrEmptyForm` instead of `nil` when the new `Configuration.FireEmptyFormError` is true (when `iris.WithEmptyFormError` is set) on missing form body to read from.
- `Configuration.EnablePathIntelligence | iris.WithPathIntelligence` to enable path intelligence automatic path redirection on the most closest path (if any), [example]((https://github.com/kataras/iris/blob/master/_examples/routing/intelligence/main.go) - `Configuration.EnablePathIntelligence | iris.WithPathIntelligence` to enable path intelligence automatic path redirection on the most closest path (if any), [example]((https://github.com/kataras/iris/blob/master/_examples/routing/intelligence/main.go)

View File

@ -27,9 +27,12 @@ func main() {
app.Post("/form_action", func(ctx iris.Context) { app.Post("/form_action", func(ctx iris.Context) {
visitor := Visitor{} visitor := Visitor{}
err := ctx.ReadForm(&visitor) err := ctx.ReadForm(&visitor)
if err != nil && !iris.IsErrPath(err) /* see: https://github.com/kataras/iris/issues/1157 */ { if err != nil {
ctx.StopWithError(iris.StatusInternalServerError, err) if !iris.IsErrPath(err) /* see: https://github.com/kataras/iris/issues/1157 */ ||
return err == iris.ErrEmptyForm {
ctx.StopWithError(iris.StatusInternalServerError, err)
return
}
} }
ctx.Writef("Visitor: %#v", visitor) ctx.Writef("Visitor: %#v", visitor)
@ -40,5 +43,5 @@ func main() {
ctx.Writef("Username: %s", username) ctx.Writef("Username: %s", username)
}) })
app.Listen(":8080") app.Listen(":8080", iris.WithEmptyFormError /* returns ErrEmptyForm if the request form body was empty */)
} }