local-server/cmd/dkl-local-server/kernel.go
2022-07-21 16:03:39 +02:00

36 lines
615 B
Go

package main
import (
"io"
"log"
"net/http"
"os"
)
func renderKernel(w http.ResponseWriter, r *http.Request, ctx *renderContext) error {
path, err := ctx.distFetch("kernels", ctx.Host.Kernel)
if err != nil {
return err
}
log.Printf("sending kernel %s for %q", ctx.Host.Kernel, ctx.Host.Name)
http.ServeFile(w, r, path)
return nil
}
func fetchKernel(out io.Writer, ctx *renderContext) (err error) {
path, err := ctx.distFetch("kernels", ctx.Host.Kernel)
if err != nil {
return err
}
in, err := os.Open(path)
if err != nil {
return
}
defer in.Close()
_, err = io.Copy(out, in)
return
}