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:
10
HISTORY.md
10
HISTORY.md
@@ -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,
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user