/* Copyright © 2023 Seednode */ package cmd import ( "bytes" "embed" "net/http" "strconv" "strings" "github.com/julienschmidt/httprouter" ) //go:embed favicons/* var favicons embed.FS const ( faviconHtml string = ` ` ) func serveFavicons(errorChannel chan<- error) httprouter.Handle { return func(w http.ResponseWriter, r *http.Request, p httprouter.Params) { fname := strings.TrimPrefix(r.URL.Path, "/") data, err := favicons.ReadFile(fname) if err != nil { return } err = w.Header().Write(bytes.NewBufferString("Content-Length: " + strconv.Itoa(len(data)))) if err != nil { errorChannel <- err return } _, err = w.Write(data) if err != nil { errorChannel <- err return } } }