...
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) clusterStatus() httpe.HandlerWithError {
24 return httpe.HandlerWithErrorFunc(func(w http.ResponseWriter, r *http.Request) error {
25 status, err := s.client.ClusterStatus(r.Context(), options(r))
26 if err != nil {
27 return err
28 }
29 return serveJSON(w, http.StatusOK, map[string]string{
30 "state": status,
31 })
32 })
33 }
34
35 func (s *Server) clusterSetup() httpe.HandlerWithError {
36 return httpe.HandlerWithErrorFunc(func(w http.ResponseWriter, r *http.Request) error {
37 var req struct {
38 Action string `json:"action"`
39 }
40 if err := s.bindJSON(r, &req); err != nil {
41 return err
42 }
43 if err := s.client.ClusterSetup(r.Context(), req.Action); err != nil {
44 return err
45 }
46 return serveJSON(w, http.StatusOK, map[string]bool{
47 "ok": true,
48 })
49 })
50 }
51
View as plain text