}
setting.NewContext()
if debug {
- setting.ProdMode = false
+ setting.RunMode = "dev"
}
}
fmt.Fprintln(os.Stderr, "Gitea:", userMessage)
if len(logMessage) > 0 {
- if !setting.ProdMode {
+ if !setting.IsProd() {
fmt.Fprintf(os.Stderr, logMessage+"\n", args...)
}
}
}
x.SetMapper(names.GonicMapper{})
- x.SetLogger(NewXORMLogger(!setting.ProdMode))
- x.ShowSQL(!setting.ProdMode)
+ x.SetLogger(NewXORMLogger(!setting.IsProd()))
+ x.ShowSQL(!setting.IsProd())
return x.StoreEngine("InnoDB").Sync2(tables...)
}
Funcs: templates.NewFuncMap(),
Asset: templates.GetAsset,
AssetNames: templates.GetAssetNames,
- IsDevelopment: setting.RunMode != "prod",
+ IsDevelopment: !setting.IsProd(),
})
return nil
}
// Although similar to macaron.Recovery() the main difference is that this error will be created
// with the gitea 500 page.
func Recovery() func(next http.Handler) http.Handler {
- var isDevelopment = setting.RunMode != "prod"
return func(next http.Handler) http.Handler {
rnd := render.New(render.Options{
Extensions: []string{".tmpl"},
Funcs: templates.NewFuncMap(),
Asset: templates.GetAsset,
AssetNames: templates.GetAssetNames,
- IsDevelopment: isDevelopment,
+ IsDevelopment: !setting.IsProd(),
})
return http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
if err := recover(); err != nil {
combinedErr := fmt.Sprintf("PANIC: %v\n%s", err, string(log.Stack(2)))
log.Error(combinedErr)
- if isDevelopment {
- http.Error(w, combinedErr, 500)
- } else {
+ if setting.IsProd() {
http.Error(w, http.StatusText(500), 500)
+ } else {
+ http.Error(w, combinedErr, 500)
}
}
}()
w.Header().Set(`X-Frame-Options`, `SAMEORIGIN`)
- if setting.RunMode != "prod" {
+ if !setting.IsProd() {
store.Data["ErrorMsg"] = combinedErr
}
err = rnd.HTML(w, 500, "status/500", templates.BaseVars().Merge(store.Data))