36 lines
615 B
Go
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
|
|
}
|