mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-10-28 22:32:24 -05:00
Static fileserver improvements, optional admin panel route (#100)
* better asset serving, optional admin panel route * linting
This commit is contained in:
parent
eef88ae31d
commit
bbc2494c58
3 changed files with 59 additions and 6 deletions
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue