mirror of
https://github.com/kataras/iris.git
synced 2026-01-23 20:05:59 +00:00
add 'Configuration.PathIntelligence' and 'OnErrorCode' and 'OnAnyErrorCode' on APIContainer
Former-commit-id: bc3d0232106622063205f326bfa4ed3aa84179de
This commit is contained in:
@@ -417,6 +417,16 @@ func (h *routerHandler) HandleRequest(ctx context.Context) {
|
||||
}
|
||||
}
|
||||
|
||||
if config.GetEnablePathIntelligence() && method == http.MethodGet {
|
||||
closestPaths := ctx.FindClosest(1)
|
||||
if len(closestPaths) > 0 {
|
||||
u := ctx.Request().URL
|
||||
u.Path = closestPaths[0]
|
||||
ctx.Redirect(u.String(), http.StatusMovedPermanently)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
ctx.StatusCode(http.StatusNotFound)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user