aboutsummaryrefslogtreecommitdiffstats
path: root/cmd/web.go
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2020-11-13 20:51:07 +0800
committerGitHub <noreply@github.com>2020-11-13 14:51:07 +0200
commitc296f4fed66288431fa7ec3a64f990beccd29eb1 (patch)
tree6b2f1971303967671bd5da1d1149407e410d62bd /cmd/web.go
parent0ae35c66f2efe608e3176f796866c18461f0780f (diff)
downloadgitea-c296f4fed66288431fa7ec3a64f990beccd29eb1.tar.gz
gitea-c296f4fed66288431fa7ec3a64f990beccd29eb1.zip
Introduce go chi web framework as frontend of macaron, so that we can move routes from macaron to chi step by step (#7420)
* When route cannot be found on chi, go to macaron * Stick chi version to 1.5.0 * Follow router log setting
Diffstat (limited to 'cmd/web.go')
-rw-r--r--cmd/web.go16
1 files changed, 7 insertions, 9 deletions
diff --git a/cmd/web.go b/cmd/web.go
index 036f1a6d66..7dcaee306c 100644
--- a/cmd/web.go
+++ b/cmd/web.go
@@ -19,8 +19,6 @@ import (
"code.gitea.io/gitea/routers"
"code.gitea.io/gitea/routers/routes"
- "gitea.com/macaron/macaron"
-
context2 "github.com/gorilla/context"
"github.com/unknwon/com"
"github.com/urfave/cli"
@@ -135,9 +133,9 @@ func runWeb(ctx *cli.Context) error {
return err
}
}
- m := routes.NewMacaron()
- routes.RegisterInstallRoute(m)
- err := listen(m, false)
+ c := routes.NewChi()
+ routes.RegisterInstallRoute(c)
+ err := listen(c, false)
select {
case <-graceful.GetManager().IsShutdown():
<-graceful.GetManager().Done()
@@ -168,10 +166,10 @@ func runWeb(ctx *cli.Context) error {
}
}
// Set up Macaron
- m := routes.NewMacaron()
- routes.RegisterRoutes(m)
+ c := routes.NewChi()
+ routes.RegisterRoutes(c)
- err := listen(m, true)
+ err := listen(c, true)
<-graceful.GetManager().Done()
log.Info("PID: %d Gitea Web Finished", os.Getpid())
log.Close()
@@ -212,7 +210,7 @@ func setPort(port string) error {
return nil
}
-func listen(m *macaron.Macaron, handleRedirector bool) error {
+func listen(m http.Handler, handleRedirector bool) error {
listenAddr := setting.HTTPAddr
if setting.Protocol != setting.UnixSocket && setting.Protocol != setting.FCGIUnix {
listenAddr = net.JoinHostPort(listenAddr, setting.HTTPPort)