package handlers import ( "net/http" "galaxy/rtmanager/internal/service/startruntime" ) // newListHandler returns the handler for `GET /api/v1/internal/runtimes`. // The handler reads directly from `ports.RuntimeRecordStore.List` — // this surface is read-only and does not produce operation_log rows // (rationale: see `rtmanager/docs/services.md` §18). func newListHandler(deps Dependencies) http.HandlerFunc { logger := loggerFor(deps.Logger, "internal_rest.list") return func(writer http.ResponseWriter, request *http.Request) { if deps.RuntimeRecords == nil { writeError(writer, http.StatusInternalServerError, startruntime.ErrorCodeInternal, "runtime records store is not wired", ) return } records, err := deps.RuntimeRecords.List(request.Context()) if err != nil { logger.ErrorContext(request.Context(), "list runtime records", "err", err.Error(), ) writeError(writer, http.StatusInternalServerError, startruntime.ErrorCodeInternal, "failed to list runtime records", ) return } writeJSON(writer, http.StatusOK, encodeRuntimesList(records)) } }