25 lines
399 B
Go
25 lines
399 B
Go
package main
|
|
|
|
import (
|
|
"encoding/json"
|
|
"log"
|
|
"net/http"
|
|
)
|
|
|
|
func renderConfig(w http.ResponseWriter, _ *http.Request, ctx *renderContext, asJson bool) (err error) {
|
|
log.Printf("sending config for %q", ctx.Host.Name)
|
|
|
|
cfgBytes, cfg, err := ctx.Config()
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
if asJson {
|
|
err = json.NewEncoder(w).Encode(cfg)
|
|
} else {
|
|
_, err = w.Write(cfgBytes)
|
|
}
|
|
|
|
return nil
|
|
}
|