Files
local-server/cmd/dkl-local-server/initrd.go

25 lines
399 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"
)
2026-02-21 14:34:53 +01:00
func renderConfig(w http.ResponseWriter, _ *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)
2026-02-21 14:34:53 +01:00
cfgBytes, cfg, err := ctx.Config()
2018-06-12 21:09:47 +11:00
if err != nil {
return err
}
2019-02-06 14:27:20 +11:00
if asJson {
err = json.NewEncoder(w).Encode(cfg)
} else {
2026-02-21 14:34:53 +01:00
_, err = w.Write(cfgBytes)
2018-06-12 21:09:47 +11:00
}
return nil
}