...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 package server
16
17 import (
18 "net/http"
19
20 "gitlab.com/flimzy/httpe"
21 )
22
23 func (s *Server) allDBsStats() httpe.HandlerWithError {
24 return httpe.HandlerWithErrorFunc(func(w http.ResponseWriter, r *http.Request) error {
25 stats, err := s.client.AllDBsStats(r.Context(), options(r))
26 if err != nil {
27 return err
28 }
29 return serveJSON(w, http.StatusOK, stats)
30 })
31 }
32
33 func (s *Server) dbsStats() httpe.HandlerWithError {
34 return httpe.HandlerWithErrorFunc(func(w http.ResponseWriter, r *http.Request) error {
35 var req struct {
36 Keys []string `json:"keys"`
37 }
38 if err := s.bind(r, &req); err != nil {
39 return err
40 }
41 stats, err := s.client.DBsStats(r.Context(), req.Keys)
42 if err != nil {
43 return err
44 }
45 return serveJSON(w, http.StatusOK, stats)
46 })
47 }
48
View as plain text