Skip to content

Commit

Permalink
metric: remove dump config api
Browse files Browse the repository at this point in the history
Signed-off-by: He Xian <[email protected]>
  • Loading branch information
hexian000 committed Nov 9, 2024
1 parent 9b93f10 commit ac23040
Showing 1 changed file with 4 additions and 30 deletions.
34 changes: 4 additions & 30 deletions v3/metric.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,10 @@ type apiConfigHandler struct {
s *Server
}

func (h *apiConfigHandler) Post(w http.ResponseWriter, r *http.Request) {
func (h *apiConfigHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
if r.Method != http.MethodPost {
w.WriteHeader(http.StatusMethodNotAllowed)
}
if r.ContentLength > maxContentLength {
w.WriteHeader(http.StatusRequestEntityTooLarge)
return
Expand All @@ -64,35 +67,6 @@ func (h *apiConfigHandler) Post(w http.ResponseWriter, r *http.Request) {
}
}

func (h *apiConfigHandler) Get(w http.ResponseWriter, r *http.Request) {
if true {
// TOTHINK: private key is in config file
w.WriteHeader(http.StatusForbidden)
return
}
cfg, _ := h.s.getConfig()
b, err := cfg.Dump()
if err != nil {
w.WriteHeader(http.StatusInternalServerError)
_, _ = w.Write([]byte(formats.Error(err)))
return
}
setRespHeader(w.Header(), "application/json", true)
w.WriteHeader(http.StatusOK)
_, _ = w.Write(b)
}

func (h *apiConfigHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
switch r.Method {
case http.MethodGet:
h.Get(w, r)
case http.MethodPost:
h.Post(w, r)
default:
w.WriteHeader(http.StatusMethodNotAllowed)
}
}

func printMemStats(w io.Writer, lastGC bool) {
var memstats runtime.MemStats
runtime.ReadMemStats(&memstats)
Expand Down

0 comments on commit ac23040

Please sign in to comment.