From 3354c7a1a67a19310074ca472034f90fba1fd743 Mon Sep 17 00:00:00 2001 From: xhe Date: Thu, 19 Oct 2023 14:31:00 +0800 Subject: [PATCH] api: add json format response (#385) --- pkg/server/api/config.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pkg/server/api/config.go b/pkg/server/api/config.go index 35b385c7..53e4351e 100644 --- a/pkg/server/api/config.go +++ b/pkg/server/api/config.go @@ -35,7 +35,12 @@ func (h *HTTPServer) ConfigSet(c *gin.Context) { } func (h *HTTPServer) ConfigGet(c *gin.Context) { - c.TOML(http.StatusOK, h.mgr.cfg.GetConfig()) + switch c.Query("format") { + case "json": + c.JSON(http.StatusOK, h.mgr.cfg.GetConfig()) + default: + c.TOML(http.StatusOK, h.mgr.cfg.GetConfig()) + } } func (h *HTTPServer) registerConfig(group *gin.RouterGroup) {