summaryrefslogtreecommitdiff
path: root/internal/web
diff options
context:
space:
mode:
Diffstat (limited to 'internal/web')
-rw-r--r--internal/web/base.go7
-rw-r--r--internal/web/fileserver.go4
2 files changed, 7 insertions, 4 deletions
diff --git a/internal/web/base.go b/internal/web/base.go
index 2759c3f9e..7be834a46 100644
--- a/internal/web/base.go
+++ b/internal/web/base.go
@@ -32,12 +32,14 @@ import (
"github.com/superseriousbusiness/gotosocial/internal/router"
)
+// Module implements the api.ClientModule interface for web pages.
type Module struct {
config *config.Config
processor processing.Processor
log *logrus.Logger
}
+// New returns a new api.ClientModule for web pages.
func New(config *config.Config, processor processing.Processor, log *logrus.Logger) api.ClientModule {
return &Module{
config: config,
@@ -62,6 +64,7 @@ func (m *Module) baseHandler(c *gin.Context) {
})
}
+// NotFoundHandler serves a 404 html page instead of a blank 404 error.
func (m *Module) NotFoundHandler(c *gin.Context) {
l := m.log.WithField("func", "404")
l.Trace("serving 404 html")
@@ -87,11 +90,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.AttachStaticFS("/assets", FileSystem{http.Dir(assetPath)})
+ 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)})
+ s.AttachStaticFS("/admin", fileSystem{http.Dir(adminPath)})
// serve front-page
s.AttachHandler(http.MethodGet, "/", m.baseHandler)
diff --git a/internal/web/fileserver.go b/internal/web/fileserver.go
index 247bf0dc8..b9a1a10fa 100644
--- a/internal/web/fileserver.go
+++ b/internal/web/fileserver.go
@@ -23,13 +23,13 @@ import (
"strings"
)
-type FileSystem struct {
+type fileSystem struct {
fs http.FileSystem
}
// FileSystem server that only accepts directory listings when an index.html is available
// from https://gist.github.com/hauxe/f2ea1901216177ccf9550a1b8bd59178
-func (fs FileSystem) Open(path string) (http.File, error) {
+func (fs fileSystem) Open(path string) (http.File, error) {
f, err := fs.fs.Open(path)
if err != nil {
return nil, err