ReadMemory returns one memory document.
(c *gin.Context)
| 287 | |
| 288 | // ReadMemory returns one memory document. |
| 289 | func (h *BaseHandlers) ReadMemory(c *gin.Context) { |
| 290 | selector := memorySelectorFromQuery(c) |
| 291 | location, err := h.resolveMemoryLocation(c.Request.Context(), c.Param("filename"), selector) |
| 292 | if err != nil { |
| 293 | h.respondMemoryError(c, StatusForMemoryError(err), err, nil) |
| 294 | return |
| 295 | } |
| 296 | if !selector.IncludeSystem && memorySystemManaged(location.Filename) { |
| 297 | err := fmt.Errorf("%w: memory %q not found", os.ErrNotExist, location.Filename) |
| 298 | h.respondMemoryError(c, StatusForMemoryError(err), err, nil) |
| 299 | return |
| 300 | } |
| 301 | |
| 302 | store, err := h.memoryStoreForLocation(c.Request.Context(), location) |
| 303 | if err != nil { |
| 304 | h.respondMemoryError(c, StatusForMemoryError(err), err, nil) |
| 305 | return |
| 306 | } |
| 307 | |
| 308 | content, err := store.Read(location.Scope, c.Param("filename")) |
| 309 | if err != nil { |
| 310 | h.respondMemoryError(c, StatusForMemoryError(err), err, nil) |
| 311 | return |
| 312 | } |
| 313 | entry, err := h.memoryEntryPayload(store, location, content) |
| 314 | if err != nil { |
| 315 | h.respondMemoryError(c, StatusForMemoryError(err), err, nil) |
| 316 | return |
| 317 | } |
| 318 | |
| 319 | c.JSON(http.StatusOK, contract.MemoryEntryResponse{Memory: entry}) |
| 320 | } |
| 321 | |
| 322 | // WriteMemory creates or proposes one Memory v2 entry. |
| 323 | func (h *BaseHandlers) WriteMemory(c *gin.Context) { |
nothing calls this directly
no test coverage detected