all repos — legit @ eda8b58d9f2e85f1bae92ce3b70f279b89031046

web frontend for git, written in go

routes/handler.go (view raw)

 1package routes
 2
 3import (
 4	"net/http"
 5
 6	"github.com/alexedwards/flow"
 7	"icyphox.sh/legit/config"
 8)
 9
10func Handlers(c *config.Config) *flow.Mux {
11	mux := flow.New()
12	d := deps{c}
13
14	mux.NotFound = http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
15		d.Write404(w)
16	})
17
18	mux.HandleFunc("/", d.Index, "GET")
19	mux.HandleFunc("/:name", d.RepoIndex, "GET")
20	mux.HandleFunc("/:name/tree/:ref/...", d.RepoTree, "GET")
21	mux.HandleFunc("/:name/blob/:ref/...", d.FileContent, "GET")
22	mux.HandleFunc("/:name/log/:ref", d.Log, "GET")
23	mux.HandleFunc("/:name/commit/:ref", d.Diff, "GET")
24	mux.HandleFunc("/:name/refs", d.Refs, "GET")
25	return mux
26}