package gateway import ( "net/http" "runtime/debug" "sig-pub/pkg/utils/resp" "sig-pub/pkg/zlog" "github.com/gin-gonic/gin" ) // grpc generic call func Route() *gin.Engine { router := gin.Default() router.Use(func(c *gin.Context) { // global recover defer func() { if r := recover(); r != nil { zlog.Error("http server recover error:", r) debug.PrintStack() c.JSON(http.StatusInternalServerError, resp.Error("server error")) c.Abort() } }() c.Next() }) router.GET("/api/hello", func(c *gin.Context) { c.JSON(http.StatusOK, resp.Success("hello")) }) return router }