Add favicon route

This commit is contained in:
Jacob Gunther
2023-07-20 14:13:25 -05:00
parent f925a29ac8
commit 484c0aceaa
3 changed files with 12 additions and 0 deletions

BIN
src/favicon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

View File

@@ -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)

View File

@@ -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"`