28 lines
579 B
Go
28 lines
579 B
Go
package httpapi
|
|
|
|
import (
|
|
"errors"
|
|
"net/http"
|
|
|
|
"tutor/internal/learnermemory"
|
|
)
|
|
|
|
func (h Handler) getLearnerMemory(w http.ResponseWriter, r *http.Request) {
|
|
if h.memory == nil {
|
|
writeError(w, http.StatusNotFound, "learner memory not configured")
|
|
return
|
|
}
|
|
|
|
snapshot, err := h.memory.Snapshot(r.PathValue("userID"))
|
|
if errors.Is(err, learnermemory.ErrProfileNotFound) {
|
|
writeError(w, http.StatusNotFound, "learner memory not found")
|
|
return
|
|
}
|
|
if err != nil {
|
|
writeError(w, http.StatusBadRequest, err.Error())
|
|
return
|
|
}
|
|
|
|
writeJSON(w, http.StatusOK, snapshot)
|
|
}
|