feat: add diagnostic interview loop

This commit is contained in:
user
2026-04-26 16:24:35 +09:00
parent 0e232ff405
commit 4a4240fea2
21 changed files with 926 additions and 23 deletions

View File

@@ -5,24 +5,27 @@ import (
"net/http"
"tutor/internal/config"
"tutor/internal/workflows"
"tutor/internal/interview"
)
type Handler struct {
cfg config.Config
runner workflows.Runner
cfg config.Config
diagnostic *interview.Service
}
func NewHandler(cfg config.Config, runner workflows.Runner) Handler {
func NewHandler(cfg config.Config, diagnostic *interview.Service) Handler {
return Handler{
cfg: cfg,
runner: runner,
cfg: cfg,
diagnostic: diagnostic,
}
}
func (h Handler) Routes() http.Handler {
mux := http.NewServeMux()
mux.HandleFunc("GET /healthz", h.health)
mux.HandleFunc("POST /api/v1/diagnostic-sessions", h.createDiagnosticSession)
mux.HandleFunc("GET /api/v1/diagnostic-sessions/{id}", h.getDiagnosticSession)
mux.HandleFunc("POST /api/v1/diagnostic-sessions/{id}/answers", h.submitDiagnosticAnswer)
return mux
}
@@ -45,3 +48,11 @@ func writeJSON(w http.ResponseWriter, status int, value any) {
w.WriteHeader(status)
_ = json.NewEncoder(w).Encode(value)
}
func writeError(w http.ResponseWriter, status int, message string) {
writeJSON(w, status, errorResponse{Error: message})
}
type errorResponse struct {
Error string `json:"error"`
}