Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

使用中间件 #234

Open
gopherhiro opened this issue Jul 13, 2023 · 0 comments
Open

使用中间件 #234

gopherhiro opened this issue Jul 13, 2023 · 0 comments

Comments

@gopherhiro
Copy link

// Recovery 中间件会 recover 任何 panic。如果有 panic 的话,会写入 500。
r.Use(gin.Recovery())

这里【Recovery 中间件会 recover 任何 panic】,这里的 panic 包含在请求中的自己新建的 goroutine 中的panic 吗?经过测试,在 主 goroutine 新建的 子 goroutine panic了,并没有被recover,程序直接终止了。请问一下,【Recovery 中间件会 recover 任何 panic】是不是并不严谨。

我是使用以下方式启动 gin 路由的。
// Default 使用 Logger 和 Recovery 中间件
r := gin.Default()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant