add path option for saveConfig API
This commit is contained in:
parent
2c82233b4f
commit
330631fd79
@ -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{
|
||||
|
Loading…
Reference in New Issue
Block a user