element/server/config.go
Evan Hazlett 2eba8d6511
wip: grpc api
Signed-off-by: Evan Hazlett <ejhazlett@gmail.com>
2017-08-14 08:39:37 -04:00

30 lines
711 B
Go

package server
import (
"encoding/json"
"fmt"
"net/http"
)
func (s *Server) apiGetConfig(w http.ResponseWriter, r *http.Request) {
cfg, err := s.proxy.Config()
if err != nil {
http.Error(w, fmt.Sprintf("error getting config: %s", err), http.StatusInternalServerError)
return
}
if err := json.NewEncoder(w).Encode(cfg); err != nil {
http.Error(w, fmt.Sprintf("error serializing config: %s", err), http.StatusInternalServerError)
return
}
}
func (s *Server) apiGetConfigRaw(w http.ResponseWriter, r *http.Request) {
cfg, err := s.proxy.Config()
if err != nil {
http.Error(w, fmt.Sprintf("error getting config: %s", err), http.StatusInternalServerError)
return
}
w.Write(cfg.Body())
}