-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Expand file tree
/
Copy pathmain.go
More file actions
28 lines (22 loc) · 555 Bytes
/
main.go
File metadata and controls
28 lines (22 loc) · 555 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
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.