completed phase 2b

This commit is contained in:
2026-05-11 20:10:45 +02:00
parent 83d96d0a1e
commit 4002a3b84d
20 changed files with 1566 additions and 50 deletions
+23 -5
View File
@@ -20,7 +20,7 @@ import (
"github.com/forgeo/forgebucket/internal/events"
)
func New(cfg *config.Config, engine *xorm.Engine, store sessions.Store, bus events.EventBus, staticFiles fs.FS) http.Handler {
func New(cfg *config.Config, engine *xorm.Engine, store sessions.Store, bus events.EventBus, artifactRoot string, staticFiles fs.FS) http.Handler {
r := chi.NewRouter()
r.Use(chimiddleware.Logger)
@@ -43,7 +43,7 @@ func New(cfg *config.Config, engine *xorm.Engine, store sessions.Store, bus even
prH := handlers.NewPRHandler(engine)
pipeH := handlers.NewPipelineHandler(engine)
wsH := handlers.NewWSHandler(bus)
gitH := handlers.NewGitHTTPHandler(engine, cfg)
gitH := handlers.NewGitHTTPHandler(engine, cfg, bus)
issueH := handlers.NewIssueHandler(engine)
sshKeyH := handlers.NewSSHKeyHandler(engine)
memberH := handlers.NewMemberHandler(engine)
@@ -56,6 +56,8 @@ func New(cfg *config.Config, engine *xorm.Engine, store sessions.Store, bus even
exploreH := handlers.NewExploreHandler(engine)
dashH := handlers.NewDashboardHandler(engine)
auditH := handlers.NewAuditHandler(engine)
artifactH := handlers.NewArtifactHandler(engine, artifactRoot)
runnerH := handlers.NewRunnerHandler(engine)
// ── Git smart-HTTP transport ───────────────────────────────────────────────
// Regex constraint ensures only *.git paths match, so asset/SPA URLs
@@ -103,6 +105,11 @@ func New(cfg *config.Config, engine *xorm.Engine, store sessions.Store, bus even
r.Get("/dashboard", dashH.Get)
r.Get("/audit", auditH.List)
r.Route("/admin", func(r chi.Router) {
r.Get("/runners", runnerH.List)
r.With(csrf).Post("/runners/register", runnerH.Register)
})
// SSH key management
r.Get("/user/keys", sshKeyH.List)
r.With(csrf).Post("/user/keys", sshKeyH.Add)
@@ -140,10 +147,21 @@ func New(cfg *config.Config, engine *xorm.Engine, store sessions.Store, bus even
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)
r.Get("/pipelines", pipeH.ListPipelines)
r.Route("/runs", func(r chi.Router) {
r.Get("/", pipeH.ListRuns)
r.Route("/{runID}", func(r chi.Router) {
r.Get("/", pipeH.GetRun)
r.With(csrf).Post("/cancel", pipeH.CancelRun)
r.Route("/jobs/{jobID}", func(r chi.Router) {
r.Get("/logs", pipeH.GetJobLogs)
r.With(csrf).Post("/retry", pipeH.RetryJob)
})
r.Get("/artifacts", artifactH.List)
r.With(csrf).Post("/artifacts", artifactH.Upload)
})
})
r.Get("/artifacts/{artifactID}/download", artifactH.Download)
r.Route("/members", func(r chi.Router) {
r.Get("/", memberH.List)
r.With(csrf).Post("/", memberH.Add)