2023-04-06 15:34:06 +00:00
|
|
|
package diagnostics
|
|
|
|
|
|
|
|
import (
|
|
|
|
"net/http"
|
|
|
|
"os"
|
2023-09-25 15:24:17 +00:00
|
|
|
"strconv"
|
|
|
|
"strings"
|
2023-04-06 15:34:06 +00:00
|
|
|
)
|
|
|
|
|
2023-08-31 08:04:27 +00:00
|
|
|
func SetupCmdLineAccess(metricsMux *http.ServeMux) {
|
2023-09-25 15:24:17 +00:00
|
|
|
metricsMux.HandleFunc("/cmdline", func(w http.ResponseWriter, r *http.Request) {
|
2023-04-06 15:34:06 +00:00
|
|
|
w.Header().Set("Access-Control-Allow-Origin", "*")
|
2023-09-25 15:24:17 +00:00
|
|
|
w.Header().Set("Content-Type", "application/json")
|
|
|
|
|
|
|
|
var space []byte
|
2023-04-06 15:34:06 +00:00
|
|
|
|
2023-09-25 15:24:17 +00:00
|
|
|
w.Write([]byte{'"'})
|
|
|
|
for _, arg := range os.Args {
|
|
|
|
if len(space) > 0 {
|
|
|
|
w.Write(space)
|
|
|
|
} else {
|
|
|
|
space = []byte(" ")
|
|
|
|
}
|
|
|
|
|
|
|
|
w.Write([]byte(strings.Trim(strconv.Quote(arg), `"`)))
|
|
|
|
}
|
|
|
|
w.Write([]byte{'"'})
|
|
|
|
})
|
2023-04-06 15:34:06 +00:00
|
|
|
}
|