You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
35 lines
614 B
35 lines
614 B
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 |
|
}
|
|
|