🎨 Improve kernel HTTP panic recover Fix https://github.com/siyuan-note/siyuan/issues/7888

This commit is contained in:
Liang Ding 2023-04-05 15:22:44 +08:00
parent 0d832cc97e
commit 813de05019
No known key found for this signature in database
GPG key ID: 136F30F901A2231D
2 changed files with 30 additions and 3 deletions

View file

@ -19,6 +19,7 @@ package model
import (
"net/http"
"strings"
"time"
"github.com/88250/gulu"
"github.com/gin-gonic/gin"
@ -230,3 +231,26 @@ func CheckAuth(c *gin.Context) {
c.Next()
}
var timingAPIs = map[string]bool{
"/api/search": true,
}
func Timing(c *gin.Context) {
now := time.Now().UnixMilli()
c.Next()
elapsed := time.Now().UnixMilli() - now
//if 000 < elapsed {
logging.LogInfof("[%s] elapsed [%dms]", c.Request.RequestURI, elapsed)
//}
}
func Recover(c *gin.Context) {
defer func() {
logging.Recover()
c.Status(500)
}()
c.Next()
}