Skip to content

Commit

Permalink
minor
Browse files Browse the repository at this point in the history
  • Loading branch information
kataras committed Jun 14, 2020
1 parent fb79081 commit c4843a4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
4 changes: 3 additions & 1 deletion HISTORY.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

- `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)

Expand Down
11 changes: 7 additions & 4 deletions _examples/request-body/read-form/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,12 @@ func main() {
app.Post("/form_action", func(ctx iris.Context) {
visitor := Visitor{}
err := ctx.ReadForm(&visitor)
if err != nil && !iris.IsErrPath(err) /* see: https://github.com/kataras/iris/issues/1157 */ {
ctx.StopWithError(iris.StatusInternalServerError, err)
return
if err != nil {
if !iris.IsErrPath(err) /* see: https://github.com/kataras/iris/issues/1157 */ ||
err == iris.ErrEmptyForm {
ctx.StopWithError(iris.StatusInternalServerError, err)
return
}
}

ctx.Writef("Visitor: %#v", visitor)
Expand All @@ -40,5 +43,5 @@ func main() {
ctx.Writef("Username: %s", username)
})

app.Listen(":8080")
app.Listen(":8080", iris.WithEmptyFormError /* returns ErrEmptyForm if the request form body was empty */)
}

0 comments on commit c4843a4

Please sign in to comment.