Cache 查看项目缓存摘要
(w http.ResponseWriter, r *http.Request)
| 274 | |
| 275 | // Cache 查看项目缓存摘要 |
| 276 | func (h *ProjectHandler) Cache(w http.ResponseWriter, r *http.Request) { |
| 277 | if r.Method != http.MethodGet { |
| 278 | http.Error(w, "Method not allowed", http.StatusMethodNotAllowed) |
| 279 | return |
| 280 | } |
| 281 | id := r.URL.Query().Get("id") |
| 282 | p := h.store.Get(id) |
| 283 | if p == nil { |
| 284 | writeJSON(w, http.StatusNotFound, map[string]string{"error": "project not found"}) |
| 285 | return |
| 286 | } |
| 287 | writeJSON(w, http.StatusOK, map[string]interface{}{ |
| 288 | "hosts": len(p.Hosts), |
| 289 | "ports": len(p.Ports), |
| 290 | "results": len(p.Results), |
| 291 | "cached_ports": h.store.CachedHostPorts(id), |
| 292 | }) |
| 293 | } |
nothing calls this directly
no test coverage detected