local-server/cmd/dkl-local-server/initrd.go
2023-08-20 11:13:51 +02:00

27 lines
428 B
Go

package main
import (
"encoding/json"
"log"
"net/http"
yaml "gopkg.in/yaml.v2"
)
func renderConfig(w http.ResponseWriter, r *http.Request, ctx *renderContext, asJson bool) (err error) {
log.Printf("sending config for %q", ctx.Host.Name)
_, cfg, err := ctx.Config()
if err != nil {
return err
}
if asJson {
err = json.NewEncoder(w).Encode(cfg)
} else {
err = yaml.NewEncoder(w).Encode(cfg)
}
return nil
}