mirror of
https://github.com/yusing/godoxy.git
synced 2026-03-27 20:01:48 +01:00
v0.5.0-rc5: check release
This commit is contained in:
@@ -9,7 +9,6 @@ import (
|
||||
U "github.com/yusing/go-proxy/api/v1/utils"
|
||||
"github.com/yusing/go-proxy/common"
|
||||
"github.com/yusing/go-proxy/config"
|
||||
E "github.com/yusing/go-proxy/error"
|
||||
"github.com/yusing/go-proxy/proxy/provider"
|
||||
)
|
||||
|
||||
@@ -32,25 +31,25 @@ func SetFileContent(w http.ResponseWriter, r *http.Request) {
|
||||
U.HandleErr(w, r, U.ErrMissingKey("filename"), http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
content, err := E.Check(io.ReadAll(r.Body))
|
||||
if err.HasError() {
|
||||
content, err := io.ReadAll(r.Body)
|
||||
if err != nil {
|
||||
U.HandleErr(w, r, err)
|
||||
return
|
||||
}
|
||||
|
||||
if filename == common.ConfigFileName {
|
||||
err = config.Validate(content)
|
||||
err = config.Validate(content).Error()
|
||||
} else {
|
||||
err = provider.Validate(content)
|
||||
err = provider.Validate(content).Error()
|
||||
}
|
||||
|
||||
if err.HasError() {
|
||||
if err != nil {
|
||||
U.HandleErr(w, r, err, http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
|
||||
err = E.From(os.WriteFile(path.Join(common.ConfigBasePath, filename), content, 0644))
|
||||
if err.HasError() {
|
||||
err = os.WriteFile(path.Join(common.ConfigBasePath, filename), content, 0644)
|
||||
if err != nil {
|
||||
U.HandleErr(w, r, err)
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user