MCPcopy Index your code
hub / github.com/mpolden/echoip / cacheHandler

Method cacheHandler

http/http.go:322–340  ·  view source on GitHub ↗
(w http.ResponseWriter, r *http.Request)

Source from the content-addressed store, hash-verified

320}
321
322func (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
342func (s *Server) DefaultHandler(w http.ResponseWriter, r *http.Request) *appError {
343 response, err := s.newResponse(r)

Callers

nothing calls this directly

Calls 5

internalServerErrorFunction · 0.85
StatsMethod · 0.80
AsJSONMethod · 0.80
HeaderMethod · 0.80
SetMethod · 0.45

Tested by

no test coverage detected