Skip to content

Commit 8e259fb

Browse files
committed
merge
1 parent 8c3b4e4 commit 8e259fb

File tree

2 files changed

+0
-74
lines changed

2 files changed

+0
-74
lines changed

routers/install/routes.go

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -107,20 +107,6 @@ func Routes() *web.Route {
107107
}))
108108

109109
r.Use(installRecovery())
110-
111-
r.Use(public.Custom(
112-
&public.Options{
113-
SkipLogging: setting.DisableRouterLog,
114-
},
115-
))
116-
r.Use(public.Static(
117-
&public.Options{
118-
Directory: path.Join(setting.StaticRootPath, "public"),
119-
SkipLogging: setting.DisableRouterLog,
120-
Prefix: "/assets",
121-
},
122-
))
123-
124110
r.Use(Init)
125111
r.Get("/", Install)
126112
r.Post("/", web.Bind(forms.InstallForm{}), SubmitInstall)

routers/web/web.go

Lines changed: 0 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,9 @@ package web
66

77
import (
88
"encoding/gob"
9-
"fmt"
109
"net/http"
1110
"os"
1211
"path"
13-
"strings"
1412

1513
"code.gitea.io/gitea/models"
1614
"code.gitea.io/gitea/modules/context"
@@ -45,7 +43,6 @@ import (
4543
"gitea.com/go-chi/captcha"
4644
"gitea.com/go-chi/session"
4745
"github.com/NYTimes/gziphandler"
48-
"github.com/chi-middleware/proxy"
4946
"github.com/go-chi/chi/middleware"
5047
"github.com/go-chi/cors"
5148
"github.com/prometheus/client_golang/prometheus"
@@ -57,63 +54,6 @@ const (
5754
GzipMinSize = 1400
5855
)
5956

60-
func commonMiddlewares() []func(http.Handler) http.Handler {
61-
var handlers = []func(http.Handler) http.Handler{
62-
func(next http.Handler) http.Handler {
63-
return http.HandlerFunc(func(resp http.ResponseWriter, req *http.Request) {
64-
next.ServeHTTP(context.NewResponse(resp), req)
65-
})
66-
},
67-
}
68-
69-
if setting.ReverseProxyLimit > 0 {
70-
opt := proxy.NewForwardedHeadersOptions().
71-
WithForwardLimit(setting.ReverseProxyLimit).
72-
ClearTrustedProxies()
73-
for _, n := range setting.ReverseProxyTrustedProxies {
74-
if !strings.Contains(n, "/") {
75-
opt.AddTrustedProxy(n)
76-
} else {
77-
opt.AddTrustedNetwork(n)
78-
}
79-
}
80-
handlers = append(handlers, proxy.ForwardedHeaders(opt))
81-
}
82-
83-
handlers = append(handlers, middleware.StripSlashes)
84-
85-
if !setting.DisableRouterLog && setting.RouterLogLevel != log.NONE {
86-
if log.GetLogger("router").GetLevel() <= setting.RouterLogLevel {
87-
handlers = append(handlers, LoggerHandler(setting.RouterLogLevel))
88-
}
89-
}
90-
if setting.EnableAccessLog {
91-
handlers = append(handlers, context.AccessLogger())
92-
}
93-
94-
handlers = append(handlers, func(next http.Handler) http.Handler {
95-
return http.HandlerFunc(func(resp http.ResponseWriter, req *http.Request) {
96-
// Why we need this? The Recovery() will try to render a beautiful
97-
// error page for user, but the process can still panic again, and other
98-
// middleware like session also may panic then we have to recover twice
99-
// and send a simple error page that should not panic any more.
100-
defer func() {
101-
if err := recover(); err != nil {
102-
combinedErr := fmt.Sprintf("PANIC: %v\n%s", err, string(log.Stack(2)))
103-
log.Error("%v", combinedErr)
104-
if setting.IsProd() {
105-
http.Error(resp, http.StatusText(500), 500)
106-
} else {
107-
http.Error(resp, combinedErr, 500)
108-
}
109-
}
110-
}()
111-
next.ServeHTTP(resp, req)
112-
})
113-
})
114-
return handlers
115-
}
116-
11757
var corsHandler func(http.Handler) http.Handler
11858

11959
// NormalRoutes represents non install routes

0 commit comments

Comments
 (0)