You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
21 lines
379 B
21 lines
379 B
package middleware |
|
|
|
import ( |
|
"github.com/gin-gonic/gin" |
|
"github.com/liangdas/mqant/log" |
|
"runtime" |
|
) |
|
|
|
func Recovery() gin.HandlerFunc { |
|
return func(c *gin.Context) { |
|
defer func() { |
|
if err := recover(); err != nil { |
|
buf := make([]byte, 1024) |
|
runtime.Stack(buf, false) |
|
log.Error("panic(%+v), stack:\n%s", err, string(buf)) |
|
return |
|
} |
|
}() |
|
c.Next() |
|
} |
|
}
|
|
|