27 lines
428 B
Go
Raw Normal View History

2018-06-12 21:09:47 +11:00
package main
import (
2019-02-06 14:27:20 +11:00
"encoding/json"
2018-06-12 21:09:47 +11:00
"log"
"net/http"
yaml "gopkg.in/yaml.v2"
)
2019-02-06 14:27:20 +11:00
func renderConfig(w http.ResponseWriter, r *http.Request, ctx *renderContext, asJson bool) (err error) {
2018-06-12 21:09:47 +11:00
log.Printf("sending config for %q", ctx.Host.Name)
_, cfg, err := ctx.Config()
if err != nil {
return err
}
2019-02-06 14:27:20 +11:00
if asJson {
err = json.NewEncoder(w).Encode(cfg)
} else {
err = yaml.NewEncoder(w).Encode(cfg)
2018-06-12 21:09:47 +11:00
}
return nil
}