Iris v12.1.1 Release Notes
Release Date: 2019-12-16 // over 4 years ago-
➕ Add Context.FindClosest(n int) []string
app := iris.New() app.OnErrorCode(iris.StatusNotFound, notFound)
func notFound(ctx iris.Context) { suggestPaths := ctx.FindClosest(3) if len(suggestPaths) == 0 { ctx.WriteString("404 not found") return } ctx.HTML("Did you mean?<ul>") for _, s := range suggestPaths { ctx.HTML(`<li><a href="%s">%s</a></li>`, s, s) } ctx.HTML("</ul>") }