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