🎨 加入只读模式配置
This commit is contained in:
parent
029982f00e
commit
877e96df4d
|
@ -65,6 +65,7 @@ type conf struct {
|
|||
Locale string // default locale
|
||||
Autocomplete bool // default autocomplete
|
||||
SiteStatCode template.HTML // site statistic code
|
||||
ReadOnly bool // read-only mode
|
||||
}
|
||||
|
||||
// Logger.
|
||||
|
|
|
@ -6,5 +6,6 @@
|
|||
"HTTPSessionMaxAge": 86400,
|
||||
"StaticResourceVersion": "${time}",
|
||||
"Locale": "zh_CN",
|
||||
"SiteStatCode": ""
|
||||
"SiteStatCode": "",
|
||||
"ReadOnly": false
|
||||
}
|
|
@ -242,6 +242,12 @@ func SaveFileHandler(w http.ResponseWriter, r *http.Request) {
|
|||
result := gulu.Ret.NewResult()
|
||||
defer gulu.Ret.RetResult(w, r, result)
|
||||
|
||||
if conf.Wide.ReadOnly {
|
||||
result.Code = -1
|
||||
result.Msg = "readonly mode"
|
||||
return
|
||||
}
|
||||
|
||||
var args map[string]interface{}
|
||||
|
||||
if err := json.NewDecoder(r.Body).Decode(&args); err != nil {
|
||||
|
|
|
@ -38,6 +38,12 @@ func BuildHandler(w http.ResponseWriter, r *http.Request) {
|
|||
result := gulu.Ret.NewResult()
|
||||
defer gulu.Ret.RetResult(w, r, result)
|
||||
|
||||
if conf.Wide.ReadOnly {
|
||||
result.Code = -1
|
||||
result.Msg = "readonly mode"
|
||||
return
|
||||
}
|
||||
|
||||
httpSession, _ := session.HTTPSession.Get(r, session.CookieName)
|
||||
if httpSession.IsNew {
|
||||
http.Error(w, "Forbidden", http.StatusForbidden)
|
||||
|
|
|
@ -37,6 +37,12 @@ func CrossCompilationHandler(w http.ResponseWriter, r *http.Request) {
|
|||
result := gulu.Ret.NewResult()
|
||||
defer gulu.Ret.RetResult(w, r, result)
|
||||
|
||||
if conf.Wide.ReadOnly {
|
||||
result.Code = -1
|
||||
result.Msg = "readonly mode"
|
||||
return
|
||||
}
|
||||
|
||||
httpSession, _ := session.HTTPSession.Get(r, session.CookieName)
|
||||
if httpSession.IsNew {
|
||||
http.Error(w, "Forbidden", http.StatusForbidden)
|
||||
|
|
|
@ -37,6 +37,12 @@ func GoInstallHandler(w http.ResponseWriter, r *http.Request) {
|
|||
result := gulu.Ret.NewResult()
|
||||
defer gulu.Ret.RetResult(w, r, result)
|
||||
|
||||
if conf.Wide.ReadOnly {
|
||||
result.Code = -1
|
||||
result.Msg = "readonly mode"
|
||||
return
|
||||
}
|
||||
|
||||
httpSession, _ := session.HTTPSession.Get(r, session.CookieName)
|
||||
if httpSession.IsNew {
|
||||
http.Error(w, "Forbidden", http.StatusForbidden)
|
||||
|
|
|
@ -48,6 +48,12 @@ func RunHandler(w http.ResponseWriter, r *http.Request, channel map[string]*util
|
|||
result := gulu.Ret.NewResult()
|
||||
defer gulu.Ret.RetResult(w, r, result)
|
||||
|
||||
if conf.Wide.ReadOnly {
|
||||
result.Code = -1
|
||||
result.Msg = "readonly mode"
|
||||
return
|
||||
}
|
||||
|
||||
var args map[string]interface{}
|
||||
|
||||
if err := json.NewDecoder(r.Body).Decode(&args); err != nil {
|
||||
|
|
Loading…
Reference in New Issue