sys_router.go 702 B

123456789101112131415161718192021222324252627282930313233
  1. package router
  2. import (
  3. "net/http"
  4. "github.com/prometheus/client_golang/prometheus/promhttp"
  5. "gitea.ckfah.com/cjjy/gocommon/pkg/net/engines"
  6. )
  7. func sysRoute(e *engines.Engine) {
  8. g := e.Group("")
  9. // 首页,prometheus,健康检查
  10. g.GET("/", welcome)
  11. g.GET("/metrics", getHandler(promhttp.Handler()))
  12. g.GET("/go-template/web_status", webStatus)
  13. }
  14. // 欢迎页面
  15. func welcome(c *engines.Context) {
  16. c.JSON(http.StatusOK, "Welcome, go-template")
  17. }
  18. // 健康检查
  19. func webStatus(c *engines.Context) {
  20. c.JSON(http.StatusOK, "status_ok")
  21. }
  22. func getHandler(handler http.Handler) engines.HandlerFunc {
  23. return func(ctx *engines.Context) {
  24. handler.ServeHTTP(ctx.Writer, ctx.Request)
  25. }
  26. }