nomadcode/services/core/internal/http/router.go
toki bb43efc8a6 feat(external-integration): 외부 통합 마일스톤 아카이브 및 HTTP 핸들러/테스트를 보강한다
- external-integration 마일스톤 아카이브 추가 (01_provider_intake_registry, 02+01_adapter_boundary)
- HTTP 핸들러에 외부 통합 관련 로직 추가
- HTTP 핸들러 테스트 케이스 보강
- HTTP 라우터 설정 추가
- 외부 통합 마일스톤 문서 업데이트
2026-06-05 04:37:40 +09:00

44 lines
1.1 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)
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
}