feat: add prometheus metrics
All checks were successful
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 2m16s

This commit is contained in:
2026-03-01 15:08:07 +08:00
parent bea436058d
commit 8aa1fe3ca7
5 changed files with 118 additions and 5 deletions

View File

@@ -7,6 +7,7 @@ import (
"go-example/hello"
"net/http"
"github.com/prometheus/client_golang/prometheus/promhttp"
"github.com/spf13/viper"
)
@@ -21,7 +22,8 @@ func main() {
flag.Parse()
conf.Init(*configPath)
http.HandleFunc("/hello", hello.Handler)
http.HandleFunc("/hello", hello.Middleware(hello.Handler))
http.Handle("/metrics", promhttp.Handler())
port := viper.GetInt("server.port")