mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-16 22:50:13 +01:00
🎨 Improve kernel HTTP panic recover Fix https://github.com/siyuan-note/siyuan/issues/7888
This commit is contained in:
parent
0d832cc97e
commit
813de05019
2 changed files with 30 additions and 3 deletions
|
|
@ -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()
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue