1
0
mirror of https://github.com/kataras/iris.git synced 2026-01-23 03:45:56 +00:00

Update to version 12.1.1 (context.FindClosest)

Former-commit-id: a57d18bab865a7c40b806c7fd2cd4ce1a259699c
This commit is contained in:
Gerasimos (Makis) Maropoulos
2019-12-16 06:50:36 +02:00
parent a3f944b884
commit af90337cfd
8 changed files with 37 additions and 6 deletions

View File

@@ -21,6 +21,33 @@ Developers are not forced to upgrade if they don't really need it. Upgrade whene
**How to upgrade**: Open your command-line and execute this command: `go get github.com/kataras/iris/v12@latest`.
# Mo, 16 December 2019 | v12.1.1
Add [Context.FindClosest(n int) []string](https://github.com/kataras/iris/blob/master/_examples/routing/not-found-suggests/main.go#L22)
```go
app := iris.New()
app.OnErrorCode(iris.StatusNotFound, notFound)
```
```go
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>")
}
```
![](https://iris-go.com/images/iris-not-found-suggests.png)
# Fr, 13 December 2019 | v12.1.0
## Breaking Changes