1
0
mirror of https://github.com/kataras/iris.git synced 2026-01-11 14:05:59 +00:00

Path type parameter error handler: add the parameter index in the input arguments

see previous commit
This commit is contained in:
Gerasimos (Makis) Maropoulos
2021-02-15 11:30:29 +02:00
parent 5990e7f432
commit e901575ca8
5 changed files with 19 additions and 12 deletions

View File

@@ -31,11 +31,15 @@ The codebase for Dependency Injection, Internationalization and localization and
- **New feature:** add the ability to set custom error handlers on path type parameters errors (existing or custom ones). Example Code:
```go
app.Macros().Get("uuid").HandleError(func(ctx iris.Context, err error) {
app.Macros().Get("uuid").HandleError(func(ctx iris.Context, paramIndex int, err error) {
ctx.StatusCode(iris.StatusBadRequest)
param := ctx.Params().GetEntryAt(paramIndex)
ctx.JSON(iris.Map{
"error": err.Error(),
"message": "invalid path parameter",
"error": err.Error(),
"message": "invalid path parameter",
"parameter": param.Key,
"value": param.ValueRaw,
})
})