cmdline query param for boot.iso

This commit is contained in:
Mikaël Cluseau
2020-03-05 00:06:49 +01:00
parent 1ee5d1c15a
commit a54d4bc15e
4 changed files with 19 additions and 4 deletions

View File

@ -7,6 +7,7 @@ import (
"io"
"log"
"net/http"
"net/url"
"path/filepath"
"text/template"
@ -20,17 +21,25 @@ import (
type renderContext struct {
Host *localconfig.Host
SSLConfig string
// Linux kernel extra cmdline
CmdLine string `yaml:"-"`
}
func renderCtx(w http.ResponseWriter, r *http.Request, ctx *renderContext, what string,
create func(out io.Writer, ctx *renderContext) error) error {
log.Printf("sending %s for %q", what, ctx.Host.Name)
tag, err := ctx.Tag()
if err != nil {
return err
}
ctx.CmdLine = r.URL.Query().Get("cmdline")
if ctx.CmdLine != "" {
what = what + "?cmdline=" + url.QueryEscape(ctx.CmdLine)
}
// get it or create it
content, meta, err := casStore.GetOrCreate(tag, what, func(out io.Writer) error {
log.Printf("building %s for %q", what, ctx.Host.Name)
@ -42,6 +51,7 @@ func renderCtx(w http.ResponseWriter, r *http.Request, ctx *renderContext, what
}
// serve it
log.Printf("sending %s for %q", what, ctx.Host.Name)
http.ServeContent(w, r, what, meta.ModTime(), content)
return nil
}