| 123456789101112131415161718192021222324252627282930313233 |
- package router
- import (
- "net/http"
- "github.com/prometheus/client_golang/prometheus/promhttp"
- "gitea.ckfah.com/cjjy/gocommon/pkg/net/engines"
- )
- func sysRoute(e *engines.Engine) {
- g := e.Group("")
- // 首页,prometheus,健康检查
- g.GET("/", welcome)
- g.GET("/metrics", getHandler(promhttp.Handler()))
- g.GET("/go-template/web_status", webStatus)
- }
- // 欢迎页面
- func welcome(c *engines.Context) {
- c.JSON(http.StatusOK, "Welcome, go-template")
- }
- // 健康检查
- func webStatus(c *engines.Context) {
- c.JSON(http.StatusOK, "status_ok")
- }
- func getHandler(handler http.Handler) engines.HandlerFunc {
- return func(ctx *engines.Context) {
- handler.ServeHTTP(ctx.Writer, ctx.Request)
- }
- }
|