-
Notifications
You must be signed in to change notification settings - Fork 171
/
settings.go
38 lines (31 loc) · 915 Bytes
/
settings.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package api
import (
"github.com/0xJacky/Nginx-UI/server/settings"
"github.com/gin-gonic/gin"
"net/http"
)
func GetSettings(c *gin.Context) {
c.JSON(http.StatusOK, gin.H{
"server": settings.ServerSettings,
"nginx_log": settings.NginxLogSettings,
})
}
func SaveSettings(c *gin.Context) {
var json struct {
Server settings.Server `json:"server"`
NginxLog settings.NginxLog `json:"nginx_log"`
}
if !BindAndValid(c, &json) {
return
}
settings.Conf.Section("server").Key("Email").SetValue(json.Server.Email)
settings.Conf.Section("server").Key("HTTPChallengePort").SetValue(json.Server.HTTPChallengePort)
settings.Conf.Section("nginx_log").Key("AccessLogPath").SetValue(json.NginxLog.AccessLogPath)
settings.Conf.Section("nginx_log").Key("ErrorLogPath").SetValue(json.NginxLog.ErrorLogPath)
err := settings.Save()
if err != nil {
ErrHandler(c, err)
return
}
GetSettings(c)
}