@@ -19,8 +19,6 @@ import (
1919 "code.gitea.io/gitea/routers/common"
2020 "code.gitea.io/gitea/routers/web/healthcheck"
2121 "code.gitea.io/gitea/services/forms"
22-
23- "gitea.com/go-chi/session"
2422)
2523
2624type dataStore map [string ]interface {}
@@ -30,7 +28,6 @@ func (d *dataStore) GetData() map[string]interface{} {
3028}
3129
3230func installRecovery (ctx goctx.Context ) func (next http.Handler ) http.Handler {
33- _ , rnd := templates .HTMLRenderer (ctx )
3431 return func (next http.Handler ) http.Handler {
3532 return http .HandlerFunc (func (w http.ResponseWriter , req * http.Request ) {
3633 defer func () {
@@ -69,6 +66,7 @@ func installRecovery(ctx goctx.Context) func(next http.Handler) http.Handler {
6966 if ! setting .IsProd {
7067 store ["ErrorMsg" ] = combinedErr
7168 }
69+ _ , rnd := templates .HTMLRenderer (ctx )
7270 err = rnd .HTML (w , http .StatusInternalServerError , "status/500" , templates .BaseVars ().Merge (store ))
7371 if err != nil {
7472 log .Error ("%v" , err )
@@ -83,34 +81,22 @@ func installRecovery(ctx goctx.Context) func(next http.Handler) http.Handler {
8381
8482// Routes registers the installation routes
8583func Routes (ctx goctx.Context ) * web.Route {
86- r := web .NewRoute ()
87- for _ , middle := range common .Middlewares () {
88- r .Use (middle )
89- }
90-
91- r .Use (web .MiddlewareWithPrefix ("/assets/" , nil , public .AssetsHandlerFunc ("/assets/" )))
92-
93- r .Use (session .Sessioner (session.Options {
94- Provider : setting .SessionConfig .Provider ,
95- ProviderConfig : setting .SessionConfig .ProviderConfig ,
96- CookieName : setting .SessionConfig .CookieName ,
97- CookiePath : setting .SessionConfig .CookiePath ,
98- Gclifetime : setting .SessionConfig .Gclifetime ,
99- Maxlifetime : setting .SessionConfig .Maxlifetime ,
100- Secure : setting .SessionConfig .Secure ,
101- SameSite : setting .SessionConfig .SameSite ,
102- Domain : setting .SessionConfig .Domain ,
103- }))
84+ base := web .NewRoute ()
85+ base .Use (common .ProtocolMiddlewares ()... )
86+ base .RouteMethods ("/assets/*" , "GET, HEAD" , public .AssetsHandlerFunc ("/assets/" ))
10487
88+ r := web .NewRoute ()
89+ r .Use (common .Sessioner ())
10590 r .Use (installRecovery (ctx ))
10691 r .Use (Init (ctx ))
10792 r .Get ("/" , Install ) // it must be on the root, because the "install.js" use the window.location to replace the "localhost" AppURL
10893 r .Post ("/" , web .Bind (forms.InstallForm {}), SubmitInstall )
10994 r .Get ("/post-install" , InstallDone )
11095 r .Get ("/api/healthz" , healthcheck .Check )
111-
11296 r .NotFound (installNotFound )
113- return r
97+
98+ base .Mount ("" , r )
99+ return base
114100}
115101
116102func installNotFound (w http.ResponseWriter , req * http.Request ) {
0 commit comments