returns the cache's statistics.
(w http.ResponseWriter, r *http.Request)
| 20 | |
| 21 | // returns the cache's statistics. |
| 22 | func getCacheStatsHandler(w http.ResponseWriter, r *http.Request) { |
| 23 | target, err := json.Marshal(cache.Stats()) |
| 24 | if err != nil { |
| 25 | w.WriteHeader(http.StatusInternalServerError) |
| 26 | log.Printf("cannot marshal cache stats. error: %s", err) |
| 27 | return |
| 28 | } |
| 29 | // since we're sending a struct, make it easy for consumers to interface. |
| 30 | w.Header().Set("Content-Type", "application/json; charset=utf-8") |
| 31 | w.Write(target) |
| 32 | return |
| 33 | } |
searching dependent graphs…