diff --git a/src/favicon.ico b/src/favicon.ico new file mode 100644 index 0000000..1131f68 Binary files /dev/null and b/src/favicon.ico differ diff --git a/src/routes.go b/src/routes.go index 9609795..5b5ae92 100644 --- a/src/routes.go +++ b/src/routes.go @@ -12,6 +12,7 @@ import ( func init() { app.Get("/ping", PingHandler) + app.Get("/favicon.ico", FaviconHandler) app.Get("/list", ListHandler) app.Get("/skin/:uuid", SkinHandler) app.Get("/face/:uuid", FaceHandler) @@ -29,6 +30,11 @@ func PingHandler(ctx *fiber.Ctx) error { return ctx.SendStatus(http.StatusOK) } +// FaviconHandler serves the favicon.ico file to any users that visit the API using a browser. +func FaviconHandler(ctx *fiber.Ctx) error { + return ctx.Type("ico").Send(favicon) +} + // ListHandler is the API handler used for the `/list` route. func ListHandler(ctx *fiber.Ctx) error { result := make([]string, 0) diff --git a/src/util.go b/src/util.go index 3aea367..d6808af 100644 --- a/src/util.go +++ b/src/util.go @@ -2,6 +2,7 @@ package main import ( "bytes" + _ "embed" "fmt" "image" "image/draw" @@ -16,6 +17,11 @@ import ( "github.com/mineatar-io/skin-render" ) +var ( + //go:embed favicon.ico + favicon []byte +) + // QueryParams is used by most all API routes as options for how the image should be rendered, or how errors should be handled. type QueryParams struct { Scale int `query:"scale"`