summaryrefslogtreecommitdiffstats
path: root/routers/routes
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2021-01-15 05:17:03 +0800
committerGitHub <noreply@github.com>2021-01-14 23:17:03 +0200
commit84b147c7f0c2575723d3471783cb24078232fe7a (patch)
tree3b7ebea85a9be9deaffceb5e836c8073a604799b /routers/routes
parent60a3297a33b2209ae7acf6fd84afd62e095e01aa (diff)
downloadgitea-84b147c7f0c2575723d3471783cb24078232fe7a.tar.gz
gitea-84b147c7f0c2575723d3471783cb24078232fe7a.zip
Use IsProd instead of testing if it's equal. (#14336)
Co-authored-by: 6543 <6543@obermui.de> Co-authored-by: zeripath <art27@cantab.net>
Diffstat (limited to 'routers/routes')
-rw-r--r--routers/routes/recovery.go11
1 files changed, 5 insertions, 6 deletions
diff --git a/routers/routes/recovery.go b/routers/routes/recovery.go
index 7f33fee0f3..cfe1a4114c 100644
--- a/routers/routes/recovery.go
+++ b/routers/routes/recovery.go
@@ -29,7 +29,6 @@ func (d *dataStore) GetData() map[string]interface{} {
// 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"},
@@ -37,7 +36,7 @@ func Recovery() func(next http.Handler) http.Handler {
Funcs: templates.NewFuncMap(),
Asset: templates.GetAsset,
AssetNames: templates.GetAssetNames,
- IsDevelopment: isDevelopment,
+ IsDevelopment: !setting.IsProd(),
})
return http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
@@ -50,10 +49,10 @@ func Recovery() func(next http.Handler) http.Handler {
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)
}
}
}()
@@ -94,7 +93,7 @@ func Recovery() func(next http.Handler) http.Handler {
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))