aboutsummaryrefslogtreecommitdiffstats
path: root/web/mux.go
blob: b6a552802167db074432366169a454f1276606ee (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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
}