making progress
This commit is contained in:
+43
-5
@@ -35,11 +35,35 @@ func New(cfg *config.Config, engine *xorm.Engine, store sessions.Store, staticFi
|
||||
csrf := middleware.CSRF(!cfg.Debug)
|
||||
auth := middleware.NewAuth(store)
|
||||
|
||||
repoH := handlers.NewRepoHandler(engine, cfg)
|
||||
userH := handlers.NewUserHandler(engine, store)
|
||||
prH := handlers.NewPRHandler(engine)
|
||||
pipeH := handlers.NewPipelineHandler(engine)
|
||||
wsH := handlers.NewWSHandler()
|
||||
repoH := handlers.NewRepoHandler(engine, cfg)
|
||||
userH := handlers.NewUserHandler(engine, store)
|
||||
prH := handlers.NewPRHandler(engine)
|
||||
pipeH := handlers.NewPipelineHandler(engine)
|
||||
wsH := handlers.NewWSHandler()
|
||||
gitH := handlers.NewGitHTTPHandler(engine, cfg)
|
||||
issueH := handlers.NewIssueHandler(engine)
|
||||
sshKeyH := handlers.NewSSHKeyHandler(engine)
|
||||
|
||||
// ── Git smart-HTTP transport ───────────────────────────────────────────────
|
||||
// These routes MUST be registered before the SPA catch-all and outside CSRF.
|
||||
// Git clients use HTTP Basic Auth, not the cookie/CSRF flow.
|
||||
r.Route("/{owner}/{repoGit}", func(r chi.Router) {
|
||||
// Only activate for paths ending in .git
|
||||
r.Use(func(next http.Handler) http.Handler {
|
||||
return http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
|
||||
rg := chi.URLParam(req, "repoGit")
|
||||
if len(rg) < 5 || rg[len(rg)-4:] != ".git" {
|
||||
// Not a git URL — skip to the next router
|
||||
http.NotFound(w, req)
|
||||
return
|
||||
}
|
||||
next.ServeHTTP(w, req)
|
||||
})
|
||||
})
|
||||
r.Get("/info/refs", gitH.ServeGit)
|
||||
r.Post("/git-upload-pack", gitH.ServeGit)
|
||||
r.Post("/git-receive-pack", gitH.ServeGit)
|
||||
})
|
||||
|
||||
r.Route("/api/v1", func(r chi.Router) {
|
||||
|
||||
@@ -71,11 +95,18 @@ func New(cfg *config.Config, engine *xorm.Engine, store sessions.Store, staticFi
|
||||
|
||||
r.Get("/me", userH.Me)
|
||||
|
||||
// SSH key management
|
||||
r.Get("/user/keys", sshKeyH.List)
|
||||
r.With(csrf).Post("/user/keys", sshKeyH.Add)
|
||||
r.With(csrf).Delete("/user/keys/{keyID}", sshKeyH.Delete)
|
||||
|
||||
r.Route("/repos", func(r chi.Router) {
|
||||
r.Get("/", repoH.List)
|
||||
r.With(csrf).Post("/", repoH.Create)
|
||||
r.Route("/{owner}/{repo}", func(r chi.Router) {
|
||||
r.Get("/", repoH.Get)
|
||||
r.With(csrf).Patch("/", repoH.Update)
|
||||
r.With(csrf).Delete("/", repoH.Delete)
|
||||
r.Get("/tree", repoH.Tree)
|
||||
r.Get("/blob", repoH.Blob)
|
||||
r.Get("/commits", repoH.Commits)
|
||||
@@ -87,6 +118,13 @@ func New(cfg *config.Config, engine *xorm.Engine, store sessions.Store, staticFi
|
||||
r.With(csrf).Post("/{prID}/merge", prH.Merge)
|
||||
r.With(csrf).Post("/{prID}/close", prH.Close)
|
||||
})
|
||||
r.Route("/issues", func(r chi.Router) {
|
||||
r.Get("/", issueH.List)
|
||||
r.With(csrf).Post("/", issueH.Create)
|
||||
r.Get("/{issueNum}", issueH.Get)
|
||||
r.With(csrf).Post("/{issueNum}/close", issueH.Close)
|
||||
r.With(csrf).Post("/{issueNum}/reopen", issueH.Reopen)
|
||||
})
|
||||
r.Route("/pipelines", func(r chi.Router) {
|
||||
r.Get("/", pipeH.List)
|
||||
r.Get("/{runID}", pipeH.Get)
|
||||
|
||||
Reference in New Issue
Block a user