diff --git a/Makefile b/Makefile index 9c1be1bd..91336e0f 100644 --- a/Makefile +++ b/Makefile @@ -56,3 +56,10 @@ serve-docs: git submodule init git submodule update hugo server -D -s docs + +favicon: + inkscape -w 16 -h 16 -o 16.png grizzly-logo-icon.svg + inkscape -w 32 -h 32 -o 32.png grizzly-logo-icon.svg + inkscape -w 64 -h 64 -o 64.png grizzly-logo-icon.svg + convert 16.png 32.png 64.png grizzly.ico + diff --git a/pkg/grizzly/embed/assets/grizzly-logo-icon.svg b/pkg/grizzly/embed/assets/grizzly-logo-icon.svg new file mode 100644 index 00000000..7f020063 --- /dev/null +++ b/pkg/grizzly/embed/assets/grizzly-logo-icon.svg @@ -0,0 +1,290 @@ + +image/svg+xml diff --git a/pkg/grizzly/embed/assets/grizzly.ico b/pkg/grizzly/embed/assets/grizzly.ico new file mode 100644 index 00000000..e61a93dc Binary files /dev/null and b/pkg/grizzly/embed/assets/grizzly.ico differ diff --git a/pkg/grizzly/server.go b/pkg/grizzly/server.go index 82cd7b97..04680b75 100644 --- a/pkg/grizzly/server.go +++ b/pkg/grizzly/server.go @@ -141,6 +141,7 @@ func (s *Server) Start() error { r.Use(middleware.Logger) r.Handle("/grizzly/assets/*", http.StripPrefix("/grizzly/assets/", http.FileServer(http.FS(assetsFS)))) + r.HandleFunc("/favicon.ico", s.faviconHandlerFunc()) for _, handler := range s.Registry.Handlers { proxyHandler, ok := handler.(ProxyHandler) @@ -320,6 +321,19 @@ func (s *Server) RootHandler(w http.ResponseWriter, _ *http.Request) { } } +func (s *Server) faviconHandlerFunc() http.HandlerFunc { + content, _ := embedFS.ReadFile("embed/assets/grizzly.ico") + + return func(w http.ResponseWriter, r *http.Request) { + w.Header().Set("Content-Type", "image/x-icon") + w.WriteHeader(http.StatusOK) + _, err := w.Write(content) + if err != nil { + log.Error(err) + } + } +} + func (s *Server) UpdateResource(name string, resource Resource) error { out, _, _, err := Format(s.Registry, s.ResourcePath, &resource, s.OutputFormat, s.OnlySpec) if err != nil {