From 330631fd79522caffaeaeb2550e16f10f7539eb3 Mon Sep 17 00:00:00 2001 From: ginuerzh Date: Fri, 17 Nov 2023 22:24:50 +0800 Subject: [PATCH] add path option for saveConfig API --- api/config.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/api/config.go b/api/config.go index 2cce93e..affa7b3 100644 --- a/api/config.go +++ b/api/config.go @@ -62,6 +62,9 @@ type saveConfigRequest struct { // output format, one of yaml|json, default is yaml. // in: query Format string `form:"format" json:"format"` + // file path, default is gost.yaml|gost.json in current working directory. + // in: query + Path string `form:"path" json:"path"` } // successful operation. @@ -92,6 +95,10 @@ func saveConfig(ctx *gin.Context) { req.Format = "yaml" } + if req.Path != "" { + file = req.Path + } + f, err := os.Create(file) if err != nil { writeError(ctx, &Error{