summaryrefslogtreecommitdiff
path: root/internal/web/base.go
diff options
context:
space:
mode:
authorLibravatar f0x52 <f0x@cthu.lu>2021-07-14 17:22:51 +0200
committerLibravatar GitHub <noreply@github.com>2021-07-14 17:22:51 +0200
commitbbc2494c58bc742b0d01a4cec6076b94b3e955de (patch)
treee395004549f8930748b71dd024be4ff2f4439817 /internal/web/base.go
parentfrontpage template tweaks (#99) (diff)
downloadgotosocial-bbc2494c58bc742b0d01a4cec6076b94b3e955de.tar.xz
Static fileserver improvements, optional admin panel route (#100)
* better asset serving, optional admin panel route * linting
Diffstat (limited to 'internal/web/base.go')
-rw-r--r--internal/web/base.go11
1 files changed, 5 insertions, 6 deletions
diff --git a/internal/web/base.go b/internal/web/base.go
index 9eea4a6ef..c0b85b613 100644
--- a/internal/web/base.go
+++ b/internal/web/base.go
@@ -24,7 +24,6 @@ import (
"os"
"path/filepath"
- "github.com/gin-contrib/static"
"github.com/gin-gonic/gin"
"github.com/sirupsen/logrus"
"github.com/superseriousbusiness/gotosocial/internal/api"
@@ -93,7 +92,11 @@ func (m *Module) Route(s router.Router) error {
return fmt.Errorf("error getting current working directory: %s", err)
}
assetPath := filepath.Join(cwd, m.config.TemplateConfig.AssetBaseDir)
- s.AttachMiddleware(static.Serve("/assets", static.LocalFile(assetPath, false)))
+ s.AttachStaticFS("/assets", FileSystem{http.Dir(assetPath)})
+
+ // Admin panel route, if it exists
+ adminPath := filepath.Join(cwd, m.config.TemplateConfig.AssetBaseDir, "/admin")
+ s.AttachStaticFS("/admin", FileSystem{http.Dir(adminPath)})
// serve front-page
s.AttachHandler(http.MethodGet, "/", m.baseHandler)
@@ -101,9 +104,5 @@ func (m *Module) Route(s router.Router) error {
// 404 handler
s.AttachNoRouteHandler(m.NotFoundHandler)
- if err != nil {
- return fmt.Errorf("error setting router FuncMap: %s", err)
- }
-
return nil
}