mirror of
https://github.com/bjdgyc/anylink.git
synced 2025-09-20 02:19:26 +08:00
修复 radius 验证测试 panic 的问题
This commit is contained in:
@@ -3,6 +3,7 @@ package admin
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"runtime/debug"
|
||||
"time"
|
||||
|
||||
"github.com/bjdgyc/anylink/base"
|
||||
@@ -120,3 +121,17 @@ func authMiddleware(next http.Handler) http.Handler {
|
||||
|
||||
return http.HandlerFunc(fn)
|
||||
}
|
||||
|
||||
func recoverHttp(next http.Handler) http.Handler {
|
||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
defer func() {
|
||||
if err := recover(); err != nil {
|
||||
stack := debug.Stack()
|
||||
base.Error(err, string(stack))
|
||||
// http.Error(w, "Internal Server Error", 500)
|
||||
RespError(w, 500, "Internal Server Error")
|
||||
}
|
||||
}()
|
||||
next.ServeHTTP(w, r)
|
||||
})
|
||||
}
|
||||
|
Reference in New Issue
Block a user