legit/routes/handler.go

26 lines
598 B
Go
Raw Normal View History

2022-12-11 05:52:47 +00:00
package routes
import (
2022-12-12 15:23:58 +00:00
"net/http"
2022-12-11 05:52:47 +00:00
"github.com/alexedwards/flow"
"icyphox.sh/legit/config"
)
func Handlers(c *config.Config) *flow.Mux {
mux := flow.New()
d := deps{c}
2022-12-12 15:23:58 +00:00
mux.NotFound = http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
d.Write404(w)
})
mux.HandleFunc("/", d.Index, "GET")
mux.HandleFunc("/:name", d.RepoIndex, "GET")
2022-12-11 08:48:39 +00:00
mux.HandleFunc("/:name/tree/:ref/...", d.RepoTree, "GET")
mux.HandleFunc("/:name/blob/:ref/...", d.FileContent, "GET")
2022-12-11 15:47:04 +00:00
mux.HandleFunc("/:name/log/:ref", d.Log, "GET")
2022-12-12 11:47:49 +00:00
mux.HandleFunc("/:name/commit/:ref", d.Diff, "GET")
2022-12-11 05:52:47 +00:00
return mux
}