(w http.ResponseWriter, r *http.Request)
| 320 | } |
| 321 | |
| 322 | func (s *Server) cacheHandler(w http.ResponseWriter, r *http.Request) *appError { |
| 323 | cacheStats := s.cache.Stats() |
| 324 | var data = struct { |
| 325 | Size int `json:"size"` |
| 326 | Capacity int `json:"capacity"` |
| 327 | Evictions uint64 `json:"evictions"` |
| 328 | }{ |
| 329 | cacheStats.Size, |
| 330 | cacheStats.Capacity, |
| 331 | cacheStats.Evictions, |
| 332 | } |
| 333 | b, err := json.MarshalIndent(data, "", " ") |
| 334 | if err != nil { |
| 335 | return internalServerError(err).AsJSON() |
| 336 | } |
| 337 | w.Header().Set("Content-Type", jsonMediaType) |
| 338 | w.Write(b) |
| 339 | return nil |
| 340 | } |
| 341 | |
| 342 | func (s *Server) DefaultHandler(w http.ResponseWriter, r *http.Request) *appError { |
| 343 | response, err := s.newResponse(r) |
nothing calls this directly
no test coverage detected