1
0
mirror of https://github.com/kataras/iris.git synced 2025-12-22 20:37:05 +00:00

new app.MiddlewareExists method

This commit is contained in:
Gerasimos (Makis) Maropoulos
2024-01-21 17:16:59 +02:00
parent 4eb7705fae
commit 66e3c26efe
8 changed files with 125 additions and 17 deletions

View File

@@ -4,6 +4,7 @@ import (
"strings"
"time"
"github.com/kataras/iris/v12/context"
"github.com/kataras/iris/v12/core/router"
"github.com/kataras/iris/v12/middleware/cors"
@@ -508,8 +509,13 @@ func (s *step7) Build() *Application {
app.SetContextErrorHandler(errors.DefaultContextErrorHandler)
app.Macros().SetErrorHandler(errors.DefaultPathParameterTypeErrorHandler)
app.UseRouter(recover.New())
app.UseRouter(s.step6.step5.routerMiddlewares...)
routeFilters := s.step6.step5.routerMiddlewares
if !context.HandlerExists(routeFilters, errors.RecoveryHandler) {
// If not errors.RecoveryHandler registered, then use the default one.
app.UseRouter(recover.New())
}
app.UseRouter(routeFilters...)
app.UseRouter(func(ctx Context) {
ctx.Header("Server", "Iris")
if dev := s.step6.step5.step4.step3.developer; dev != "" {