about summary refs log tree commit diff stats
path: root/internal/server/server.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/server/server.go')
-rw-r--r--internal/server/server.go12
1 files changed, 10 insertions, 2 deletions
diff --git a/internal/server/server.go b/internal/server/server.go
index b5526a0..e4ff63b 100644
--- a/internal/server/server.go
+++ b/internal/server/server.go
@@ -16,6 +16,7 @@ import (
 
 	"go.alanpearce.eu/website/internal/builder"
 	cfg "go.alanpearce.eu/website/internal/config"
+	"go.alanpearce.eu/website/internal/storage/files"
 	"go.alanpearce.eu/website/internal/vcs"
 	"go.alanpearce.eu/website/internal/website"
 	"go.alanpearce.eu/x/log"
@@ -174,7 +175,14 @@ func New(runtimeConfig *Config, log *log.Logger) (*Server, error) {
 	}
 
 	loggingMux := http.NewServeMux()
-	mux, err := website.NewMux(config, runtimeConfig.Root, log.Named("website"))
+
+	log.Debug("registering content files", "root", runtimeConfig.Root)
+	reader, err := files.NewReader(runtimeConfig.Root, log.Named("files"))
+	if err != nil {
+		return nil, errors.WithMessage(err, "could not create file reader")
+	}
+
+	mux, err := website.NewMux(config, reader, log.Named("website"))
 	if err != nil {
 		return nil, errors.WithMessage(err, "could not create website mux")
 	}
@@ -188,7 +196,7 @@ func New(runtimeConfig *Config, log *log.Logger) (*Server, error) {
 		loggingMux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
 			switch {
 			case slices.Contains(config.Domains, r.Host):
-				path, _ := website.CanonicalisePath(r.URL.Path)
+				path, _ := reader.CanonicalisePath(r.URL.Path)
 				http.Redirect(
 					w,
 					r,