nomadcode/services/core/internal/http/router.go
toki f23ba78eba feat: plane webhook intake & protosocket consumer wire readiness
- Add Plane webhook handler for issue events (created, state, assignees)
- Add Plane webhook integration tests with testdata fixtures
- Add Gito Protosocket consumer wire readiness milestone
- Add Plane work item webhook intake milestone
- Add agent-task for plane-work-item-webhook-intake (trigger dispatch, idempotency, live smoke)
- Update service config, router, handlers for Plane webhook endpoints
- Add SOPS env setup script and secrets configuration
- Update agent-ops domain rules and phase roadmap
2026-06-14 20:37:48 +09:00

45 lines
1.2 KiB
Go

package http
import (
"log/slog"
stdhttp "net/http"
"github.com/go-chi/chi/v5"
chimiddleware "github.com/go-chi/chi/v5/middleware"
)
type AuthConfig struct {
Username string
Password string
}
func NewRouter(handler *Handler, logger *slog.Logger, auth AuthConfig, protoSocket stdhttp.Handler, protoSocketPath string) stdhttp.Handler {
r := chi.NewRouter()
r.Use(chimiddleware.RequestID)
r.Use(chimiddleware.RealIP)
r.Use(loggingMiddleware(logger))
r.Use(chimiddleware.Recoverer)
r.Get("/healthz", handler.Healthz)
r.Post("/api/integrations/plane/webhook", handler.ReceivePlaneWebhook)
protected := chi.NewRouter()
protected.Use(basicAuthMiddleware(auth))
protected.Get("/readyz", handler.Readyz)
if protoSocket != nil && protoSocketPath != "" {
protected.Handle(protoSocketPath, protoSocket)
}
protected.Route("/api", func(r chi.Router) {
r.Post("/integrations/plane/tasks", handler.CreatePlaneTask)
r.Post("/integrations/{provider}/tasks", handler.CreateWorkItemTask)
r.Post("/tasks", handler.CreateTask)
r.Get("/tasks", handler.ListTasks)
r.Get("/tasks/{id}", handler.GetTask)
r.Post("/tasks/{id}/enqueue", handler.EnqueueTask)
})
r.Mount("/", protected)
return r
}