mirror of
https://github.com/kataras/iris.git
synced 2025-12-21 03:47:04 +00:00
Add notes for the new lead maintainer of the open-source iris project and align with @get-ion/ion by @hiveminded
Former-commit-id: da4f38eb9034daa49446df3ee529423b98f9b331
This commit is contained in:
30
_examples/miscellaneous/recover/main.go
Normal file
30
_examples/miscellaneous/recover/main.go
Normal file
@@ -0,0 +1,30 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/kataras/iris"
|
||||
"github.com/kataras/iris/context"
|
||||
|
||||
"github.com/kataras/iris/middleware/recover"
|
||||
)
|
||||
|
||||
func main() {
|
||||
app := iris.New()
|
||||
// use this recover(y) middleware
|
||||
app.Use(recover.New())
|
||||
|
||||
i := 0
|
||||
// let's simmilate a panic every next request
|
||||
app.Get("/", func(ctx context.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.Run(iris.Addr(":8080"))
|
||||
}
|
||||
|
||||
// Note:
|
||||
// app := iris.Default() instead of iris.New() makes use of the recovery middleware automatically.
|
||||
Reference in New Issue
Block a user