1
0
mirror of https://github.com/kataras/iris.git synced 2025-12-20 03:17:04 +00:00

add some api helpers

This commit is contained in:
kataras
2022-05-05 02:46:15 +03:00
parent 4a43cd1fbb
commit 10c1542daf
5 changed files with 56 additions and 1 deletions

View File

@@ -595,3 +595,17 @@ func (ms *Macros) GetTrailings() (macros []*Macro) {
return
}
// SetErrorHandler registers a common type path parameter error handler.
// The "fnHandler" MUST be a type of handler.ParamErrorHandler:
// func(ctx iris.Context, paramIndex int, err error). It calls
// the Macro.HandleError method for each of the "ms" entries.
func (ms *Macros) SetErrorHandler(fnHandler interface{}) {
for _, m := range *ms {
if m == nil {
continue
}
m.HandleError(fnHandler)
}
}