[change] control, openapi: Handle upstreams test with JSON

This commit is contained in:
Aleksey Dmitrevskiy
2019-03-05 12:29:52 +03:00
parent d9d641941c
commit e973c4b174
2 changed files with 22 additions and 14 deletions

View File

@@ -361,12 +361,12 @@ func checkBootstrapDNS(host string) error {
func handleTestUpstreamDNS(w http.ResponseWriter, r *http.Request) {
log.Tracef("%s %v", r.Method, r.URL)
body, err := ioutil.ReadAll(r.Body)
hosts := []string{}
err := json.NewDecoder(r.Body).Decode(&hosts)
if err != nil {
httpError(w, http.StatusBadRequest, "Failed to read request body: %s", err)
return
}
hosts := strings.Fields(string(body))
if len(hosts) == 0 {
httpError(w, http.StatusBadRequest, "No servers specified")