Fix: updateConfig api crash

This commit is contained in:
Dreamacro
2018-08-26 22:43:38 +08:00
parent ad25a89dd2
commit 2a2e61652f
4 changed files with 22 additions and 9 deletions

View File

@ -21,6 +21,7 @@ func configRouter() http.Handler {
type configSchema struct {
Port int `json:"port"`
SocksPort int `json:"socket-port"`
RedirPort int `json:"redir-port"`
AllowLan bool `json:"allow-lan"`
Mode string `json:"mode"`
LogLevel string `json:"log-level"`
@ -31,6 +32,7 @@ func getConfigs(w http.ResponseWriter, r *http.Request) {
render.JSON(w, r, configSchema{
Port: general.Port,
SocksPort: general.SocksPort,
RedirPort: general.RedirPort,
AllowLan: general.AllowLan,
Mode: general.Mode.String(),
LogLevel: general.LogLevel.String(),
@ -87,6 +89,7 @@ func updateConfigs(w http.ResponseWriter, r *http.Request) {
AllowLan: general.AllowLan,
Port: general.Port,
SocksPort: general.SocksPort,
RedirPort: general.RedirPort,
})
w.WriteHeader(http.StatusNoContent)