Skip to content

Commit

Permalink
Serve favicons over mux
Browse files Browse the repository at this point in the history
  • Loading branch information
jmattheis committed Dec 7, 2019
1 parent 17aea13 commit 1ad4488
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions ui/serve.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package ui

import (
"fmt"
"net/http"

"github.com/gobuffalo/packr/v2"
Expand All @@ -15,6 +16,12 @@ func Register(r *mux.Router, box *packr.Box) {
r.Handle("/service-worker.js", serveFile("service-worker.js", "text/javascript", box))
r.Handle("/assets-manifest.json", serveFile("asserts-manifest.json", "application/json", box))
r.Handle("/static/{type}/{resource}", http.FileServer(box))

r.Handle("/favicon.ico", serveFile("favicon.ico", "image/x-icon", box))
for _, size := range []string{"16x16", "32x32", "192x192", "256x256"} {
fileName := fmt.Sprintf("/favicon-%s.png", size)
r.Handle(fileName, serveFile(fileName, "image/png", box))
}
}

func serveFile(name, contentType string, box *packr.Box) http.HandlerFunc {
Expand Down

0 comments on commit 1ad4488

Please sign in to comment.