aboutsummaryrefslogtreecommitdiffstats
path: root/web/mux.go
diff options
context:
space:
mode:
Diffstat (limited to 'web/mux.go')
-rw-r--r--web/mux.go21
1 files changed, 21 insertions, 0 deletions
diff --git a/web/mux.go b/web/mux.go
new file mode 100644
index 0000000..b6a5528
--- /dev/null
+++ b/web/mux.go
@@ -0,0 +1,21 @@
+package web
+
+import (
+ "net/http"
+
+ "github.com/LMBishop/scrapbook/pkg/config"
+ "github.com/LMBishop/scrapbook/pkg/index"
+ "github.com/LMBishop/scrapbook/web/command/handler"
+)
+
+func NewMux(cfg *config.MainConfig, siteIndex *index.SiteIndex) *http.ServeMux {
+ mux := http.NewServeMux()
+ mux.HandleFunc("GET /", handler.GetHome(cfg, siteIndex))
+ mux.HandleFunc("GET /create", handler.GetCreate())
+ mux.HandleFunc("POST /create", handler.PostCreate(cfg, siteIndex))
+ mux.HandleFunc("GET /site/{site}/", handler.GetSite(cfg, siteIndex))
+ mux.HandleFunc("GET /site/{site}/upload", handler.GetUpload(siteIndex))
+ mux.HandleFunc("POST /site/{site}/upload", handler.PostUpload(cfg, siteIndex))
+
+ return mux
+}