1
0
mirror of https://github.com/kataras/iris.git synced 2026-01-10 21:45:57 +00:00

add new ':email' path parameter and revert the jsoniter removal

This commit is contained in:
Gerasimos (Makis) Maropoulos
2021-10-13 16:22:22 +03:00
parent a9b97e005a
commit bf54d33a3e
15 changed files with 179 additions and 101 deletions

View File

@@ -28,6 +28,34 @@ The codebase for Dependency Injection, Internationalization and localization and
## Fixes and Improvements
- New `email` builtin path parameter type. Example:
```go
// +------------------------+
// | {param:email} |
// +------------------------+
// Email + mx look up path parameter validation. Use it on production.
// http://localhost:8080/user/kataras2006@hotmail.com -> OK
// http://localhost:8080/user/b-c@invalid_domain -> NOT FOUND
app.Get("/user/{user_email:email}", func(ctx iris.Context) {
email := ctx.Params().Get("user_email")
ctx.WriteString(email)
})
// +------------------------+
// | {param:mail} |
// +------------------------+
// Simple email path parameter validation.
// http://localhost:8080/user/kataras2006@hotmail.com -> OK
// http://localhost:8080/user/b-c@invalid_domainxxx1.com -> NOT FOUND
app.Get("/user/{local_email:mail}", func(ctx iris.Context) {
email := ctx.Params().Get("local_email")
ctx.WriteString(email)
})
```
- New `iris.IsErrEmptyJSON(err) bool` which reports whether the given "err" is caused by a
`Context.ReadJSON` call when the request body didn't start with { (or it was totally empty).