This is an automated email from the git hooks/post-receive script. New commit to branch bow-v2-go in repository bow. See https://gitlab.nuiton.org/chorem/bow.git commit c8948f5c54f68f5993db775595281f0a67b3d494 Author: Benjamin <poussin@codelutin.com> Date: Tue Aug 18 17:51:37 2020 +0200 ajout du monitoring --- go.mod | 1 + go.sum | 1 + pkg/http/router.go | 7 ++++++- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/go.mod b/go.mod index d6dd960..7ca9eaa 100644 --- a/go.mod +++ b/go.mod @@ -11,5 +11,6 @@ require ( github.com/mitchellh/go-server-timing v1.0.0 github.com/pkg/errors v0.9.1 // indirect golang.org/x/crypto v0.0.0-20200403201458-baeed622b8d8 + golang.org/x/net v0.0.0-20190813141303-74dc4d7220e7 golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 // indirect ) diff --git a/go.sum b/go.sum index 8ef6f3d..ac0f52b 100644 --- a/go.sum +++ b/go.sum @@ -134,6 +134,7 @@ golang.org/x/crypto v0.0.0-20200403201458-baeed622b8d8/go.mod h1:LzIPMQfyMNhhGPh golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20190813141303-74dc4d7220e7 h1:fHDIZ2oxGnUZRN6WgWFCbYBjH9uqVPRCUVUDhs0wnbA= golang.org/x/net v0.0.0-20190813141303-74dc4d7220e7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= diff --git a/pkg/http/router.go b/pkg/http/router.go index bb792ea..daeb414 100644 --- a/pkg/http/router.go +++ b/pkg/http/router.go @@ -2,6 +2,9 @@ package http import ( "context" + // ajout du monitoring de go (memoire, allocation, ...) + // endpoint /debug/vars + "expvar" "fmt" "io" "log" @@ -36,11 +39,13 @@ func Start(bowPublicURL string, addr string) { // router.Use(mux.CORSMethodMiddleware(router)) router.Use(cors) router.Use(authentication) + // router.Handle("/debug/{*}", http.DefaultServeMux) // router.HandleFunc("/", handler404) s := router.PathPrefix("/api/v1").Subrouter() s.HandleFunc("/system/liveness", isAlive).Methods(http.MethodGet, http.MethodOptions) + s.Handle("/system/metrics", expvar.Handler()).Methods(http.MethodGet, http.MethodOptions) s.HandleFunc("/system/stats", getStats).Methods(http.MethodGet, http.MethodOptions) s.HandleFunc("/users", createUser).Methods(http.MethodPost, http.MethodOptions) s.HandleFunc("/users/auth", createAuth).Methods(http.MethodPost, http.MethodOptions) @@ -143,7 +148,7 @@ func withoutAuthenticationEndpoint(r *http.Request) bool { } func needAdminEndpoint(r *http.Request) bool { - result := strings.HasSuffix(r.URL.Path, "/system/stats") + result := strings.HasSuffix(r.URL.Path, "/system/") return result } -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.