feat: add diagnostic interview loop
This commit is contained in:
@@ -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"`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user