(c *Core, w *ResponseWriter, r *Request)
| 209 | } |
| 210 | |
| 211 | func handlePoolStats(c *Core, w *ResponseWriter, r *Request) { |
| 212 | pool, ok := r.openPool(w, c.root) |
| 213 | if !ok { |
| 214 | return |
| 215 | } |
| 216 | //XXX app uses this for key range... should handle this differently |
| 217 | // at minimum on a per-branch basis and app needs to be branch aware |
| 218 | // If branch not specified, API endpoints here should just assume "main". |
| 219 | branch, err := pool.OpenBranchByName(r.Context(), "main") |
| 220 | if err != nil { |
| 221 | w.Error(err) |
| 222 | return |
| 223 | } |
| 224 | snap, err := branch.Pool().Snapshot(r.Context(), branch.Commit) |
| 225 | if err != nil { |
| 226 | if errors.Is(err, journal.ErrEmpty) { |
| 227 | w.WriteHeader(http.StatusNoContent) |
| 228 | return |
| 229 | } |
| 230 | w.Error(err) |
| 231 | return |
| 232 | } |
| 233 | info, err := exec.GetPoolStats(r.Context(), pool, snap) |
| 234 | if err != nil { |
| 235 | w.Error(err) |
| 236 | return |
| 237 | } |
| 238 | w.Respond(http.StatusOK, info) |
| 239 | } |
| 240 | |
| 241 | func handlePoolPost(c *Core, w *ResponseWriter, r *Request) { |
| 242 | var req api.PoolPostRequest |
nothing calls this directly
no test coverage detected