config dump endpoint for proxy

This commit is contained in:
A.Unger
2021-11-09 14:14:31 +01:00
parent 26aa37c2d7
commit c335c4dc29
3 changed files with 28 additions and 0 deletions

View File

@@ -1,6 +1,7 @@
package debug
import (
"encoding/json"
"io"
"net/http"
@@ -22,6 +23,7 @@ func Server(opts ...Option) (*http.Server, error) {
debug.Zpages(options.Config.Debug.Zpages),
debug.Health(health(options.Config)),
debug.Ready(ready(options.Config)),
debug.ConfigDump(configDump(options.Config)),
), nil
}
@@ -52,3 +54,17 @@ func ready(cfg *config.Config) func(http.ResponseWriter, *http.Request) {
}
}
}
// configDump implements the config dump
func configDump(cfg *config.Config) func(http.ResponseWriter, *http.Request) {
return func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json")
b, err := json.Marshal(cfg)
if err != nil {
w.WriteHeader(http.StatusInternalServerError)
}
_, _ = w.Write(b)
}
}