app/vmagent: list user-visible endpoints at http://vmagent:8429/

While at it, use common WriteAPIHelp function for the listing in vmagent, vmalert and victoria-metrics
This commit is contained in:
Aliaksandr Valialkin
2021-04-30 09:19:08 +03:00
parent 2ab1266593
commit 6fa5981e68
5 changed files with 32 additions and 28 deletions

View File

@@ -11,6 +11,7 @@ import (
"net"
"net/http"
"net/http/pprof"
"path"
"runtime"
"strconv"
"strings"
@@ -589,3 +590,12 @@ func IsTLS() bool {
func GetPathPrefix() string {
return *pathPrefix
}
// WriteAPIHelp writes pathList to w in HTML format.
func WriteAPIHelp(w io.Writer, pathList [][2]string) {
for _, p := range pathList {
p, doc := p[0], p[1]
p = path.Join(*pathPrefix, p)
fmt.Fprintf(w, "<a href=%q>%s</a> - %s<br/>", p, p, doc)
}
}