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

reorganization of _examples and add some new examples such as iris+groupcache+mysql+docker

Former-commit-id: ed635ee95de7160cde11eaabc0c1dcb0e460a620
This commit is contained in:
Gerasimos (Makis) Maropoulos
2020-06-07 15:26:06 +03:00
parent 9fdcb4c7fb
commit ed45c77be5
328 changed files with 4262 additions and 41621 deletions

28
_examples/recover/main.go Normal file
View File

@@ -0,0 +1,28 @@
package main
import (
"github.com/kataras/iris/v12"
"github.com/kataras/iris/v12/middleware/recover"
)
func main() {
app := iris.New()
app.Use(recover.New())
i := 0
// let's simulate a panic every next request
app.Get("/", func(ctx iris.Context) {
i++
if i%2 == 0 {
panic("a panic here")
}
ctx.Writef("Hello, refresh one time more to get panic!")
})
// http://localhost:8080, refresh it 5-6 times.
app.Listen(":8080")
}
// Note:
// app := iris.Default() instead of iris.New() makes use of the recovery middleware automatically.