2017-07-30 02:54:43 +00:00
|
|
|
package server
|
|
|
|
|
|
|
|
import (
|
|
|
|
"encoding/json"
|
|
|
|
"fmt"
|
|
|
|
"net/http"
|
|
|
|
)
|
|
|
|
|
2017-08-14 12:39:37 +00:00
|
|
|
func (s *Server) apiGetConfig(w http.ResponseWriter, r *http.Request) {
|
2017-07-30 02:54:43 +00:00
|
|
|
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
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-08-14 12:39:37 +00:00
|
|
|
func (s *Server) apiGetConfigRaw(w http.ResponseWriter, r *http.Request) {
|
2017-07-30 02:54:43 +00:00
|
|
|
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())
|
|
|
|
}
|