aboutsummaryrefslogtreecommitdiffstats
path: root/routers
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2021-10-20 22:37:19 +0800
committerGitHub <noreply@github.com>2021-10-20 16:37:19 +0200
commitf494776931b71f83fdfdd4e68e850529c4b2614f (patch)
tree92b3779237dadfe042d3f93e9ddaaaac5d6d385f /routers
parent0208ea0248782a994771cadf0af6a4125fdde723 (diff)
downloadgitea-f494776931b71f83fdfdd4e68e850529c4b2614f.tar.gz
gitea-f494776931b71f83fdfdd4e68e850529c4b2614f.zip
Use a variable but a function for IsProd because of a slight performance increment (#17368)
Diffstat (limited to 'routers')
-rw-r--r--routers/common/middleware.go2
-rw-r--r--routers/install/routes.go4
-rw-r--r--routers/web/base.go4
-rw-r--r--routers/web/web.go2
4 files changed, 6 insertions, 6 deletions
diff --git a/routers/common/middleware.go b/routers/common/middleware.go
index 1d96522dd9..7c5c72f5cc 100644
--- a/routers/common/middleware.go
+++ b/routers/common/middleware.go
@@ -62,7 +62,7 @@ func Middlewares() []func(http.Handler) http.Handler {
if err := recover(); err != nil {
combinedErr := fmt.Sprintf("PANIC: %v\n%s", err, string(log.Stack(2)))
log.Error("%v", combinedErr)
- if setting.IsProd() {
+ if setting.IsProd {
http.Error(resp, http.StatusText(500), 500)
} else {
http.Error(resp, combinedErr, 500)
diff --git a/routers/install/routes.go b/routers/install/routes.go
index e9aca85d8e..ad0003a9e8 100644
--- a/routers/install/routes.go
+++ b/routers/install/routes.go
@@ -40,7 +40,7 @@ func installRecovery() 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 setting.IsProd() {
+ if setting.IsProd {
http.Error(w, http.StatusText(500), 500)
} else {
http.Error(w, combinedErr, 500)
@@ -63,7 +63,7 @@ func installRecovery() func(next http.Handler) http.Handler {
w.Header().Set(`X-Frame-Options`, setting.CORSConfig.XFrameOptions)
- if !setting.IsProd() {
+ if !setting.IsProd {
store["ErrorMsg"] = combinedErr
}
err = rnd.HTML(w, 500, "status/500", templates.BaseVars().Merge(store))
diff --git a/routers/web/base.go b/routers/web/base.go
index f50c5229b1..16d3192da2 100644
--- a/routers/web/base.go
+++ b/routers/web/base.go
@@ -131,7 +131,7 @@ func Recovery() func(next http.Handler) http.Handler {
sessionStore := session.GetSession(req)
if sessionStore == nil {
- if setting.IsProd() {
+ if setting.IsProd {
http.Error(w, http.StatusText(500), 500)
} else {
http.Error(w, combinedErr, 500)
@@ -164,7 +164,7 @@ func Recovery() func(next http.Handler) http.Handler {
w.Header().Set(`X-Frame-Options`, setting.CORSConfig.XFrameOptions)
- if !setting.IsProd() {
+ if !setting.IsProd {
store["ErrorMsg"] = combinedErr
}
err = rnd.HTML(w, 500, "status/500", templates.BaseVars().Merge(store))
diff --git a/routers/web/web.go b/routers/web/web.go
index caec067671..88565d6d85 100644
--- a/routers/web/web.go
+++ b/routers/web/web.go
@@ -477,7 +477,7 @@ func RegisterRoutes(m *web.Route) {
m.Post("/action/{action}", user.Action)
}, reqSignIn)
- if !setting.IsProd() {
+ if !setting.IsProd {
m.Get("/template/*", dev.TemplatePreview)
}