Skip to main content
Glama
recovery.go606 B
package middleware import ( "fmt" "github.com/gin-gonic/gin" "github.com/weibaohui/k8m/pkg/comm/utils/amis" "k8s.io/klog/v2" ) // CustomRecovery 是自定义的 Recovery 中间件 func CustomRecovery() gin.HandlerFunc { return func(c *gin.Context) { defer func() { if err := recover(); err != nil { // 打印错误日志(可选) klog.Errorf("捕获到 panic: %v\n", err) // 返回友好的错误信息 amis.WriteJsonError(c, fmt.Errorf("服务器内部错误,请稍后再试。")) c.Abort() } }() c.Next() // 继续执行下一个中间件或处理函数 } }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/weibaohui/k8m'

If you have feedback or need assistance with the MCP directory API, please join our Discord server