fix ws config as yaml
This commit is contained in:
@ -4,14 +4,12 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
yaml "gopkg.in/yaml.v2"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func renderConfig(w http.ResponseWriter, r *http.Request, ctx *renderContext, asJson bool) (err error) {
|
func renderConfig(w http.ResponseWriter, _ *http.Request, ctx *renderContext, asJson bool) (err error) {
|
||||||
log.Printf("sending config for %q", ctx.Host.Name)
|
log.Printf("sending config for %q", ctx.Host.Name)
|
||||||
|
|
||||||
_, cfg, err := ctx.Config()
|
cfgBytes, cfg, err := ctx.Config()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -19,7 +17,7 @@ func renderConfig(w http.ResponseWriter, r *http.Request, ctx *renderContext, as
|
|||||||
if asJson {
|
if asJson {
|
||||||
err = json.NewEncoder(w).Encode(cfg)
|
err = json.NewEncoder(w).Encode(cfg)
|
||||||
} else {
|
} else {
|
||||||
err = yaml.NewEncoder(w).Encode(cfg)
|
_, err = w.Write(cfgBytes)
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
Reference in New Issue
Block a user