mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-05-31 20:02:09 +00:00
Improve assets handler middleware (#15961)
* Use route to serve assets but not middleware * Fix build error with bindata tag * convert path to absolute * fix build * reduce function stack * Add tests for assets * Remove test for assets because they are not generated * Use a http function to serve assets * Still use middleware to serve assets then less middleware stack for assets * Move serveContent to original position * remove unnecessary blank line change * Fix bug for /assets* requests * clean code Co-authored-by: zeripath <art27@cantab.net>
This commit is contained in:
parent
d79c8bc302
commit
effad26c0e
6 changed files with 108 additions and 167 deletions
|
@ -81,6 +81,11 @@ func InstallRoutes() *web.Route {
|
|||
r.Use(middle)
|
||||
}
|
||||
|
||||
r.Use(public.AssetsHandler(&public.Options{
|
||||
Directory: path.Join(setting.StaticRootPath, "public"),
|
||||
Prefix: "/assets",
|
||||
}))
|
||||
|
||||
r.Use(session.Sessioner(session.Options{
|
||||
Provider: setting.SessionConfig.Provider,
|
||||
ProviderConfig: setting.SessionConfig.ProviderConfig,
|
||||
|
@ -93,20 +98,6 @@ func InstallRoutes() *web.Route {
|
|||
}))
|
||||
|
||||
r.Use(installRecovery())
|
||||
|
||||
r.Use(public.Custom(
|
||||
&public.Options{
|
||||
SkipLogging: setting.DisableRouterLog,
|
||||
},
|
||||
))
|
||||
r.Use(public.Static(
|
||||
&public.Options{
|
||||
Directory: path.Join(setting.StaticRootPath, "public"),
|
||||
SkipLogging: setting.DisableRouterLog,
|
||||
Prefix: "/assets",
|
||||
},
|
||||
))
|
||||
|
||||
r.Use(routers.InstallInit)
|
||||
r.Get("/", routers.Install)
|
||||
r.Post("/", web.Bind(forms.InstallForm{}), routers.InstallPost)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue