Add favicon route
This commit is contained in:
BIN
src/favicon.ico
Normal file
BIN
src/favicon.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 13 KiB |
@@ -10,6 +10,7 @@ import (
|
|||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
app.Get("/ping", PingHandler)
|
app.Get("/ping", PingHandler)
|
||||||
|
app.Get("/favicon.ico", FaviconHandler)
|
||||||
app.Get("/status/java/:address", JavaStatusHandler)
|
app.Get("/status/java/:address", JavaStatusHandler)
|
||||||
app.Get("/status/bedrock/:address", BedrockStatusHandler)
|
app.Get("/status/bedrock/:address", BedrockStatusHandler)
|
||||||
app.Get("/icon", DefaultIconHandler)
|
app.Get("/icon", DefaultIconHandler)
|
||||||
@@ -22,6 +23,11 @@ func PingHandler(ctx *fiber.Ctx) error {
|
|||||||
return ctx.SendStatus(http.StatusOK)
|
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)
|
||||||
|
}
|
||||||
|
|
||||||
// JavaStatusHandler returns the status of the Java edition Minecraft server specified in the address parameter.
|
// JavaStatusHandler returns the status of the Java edition Minecraft server specified in the address parameter.
|
||||||
func JavaStatusHandler(ctx *fiber.Ctx) error {
|
func JavaStatusHandler(ctx *fiber.Ctx) error {
|
||||||
host, port, err := ParseAddress(ctx.Params("address"), 25565)
|
host, port, err := ParseAddress(ctx.Params("address"), 25565)
|
||||||
|
|||||||
@@ -18,8 +18,10 @@ import (
|
|||||||
var (
|
var (
|
||||||
//go:embed icon.png
|
//go:embed icon.png
|
||||||
defaultIconBytes []byte
|
defaultIconBytes []byte
|
||||||
blockedServers *MutexArray[string] = nil
|
//go:embed favicon.ico
|
||||||
ipAddressRegex *regexp.Regexp = regexp.MustCompile(`^\d{1,3}(\.\d{1,3}){3}$`)
|
favicon []byte
|
||||||
|
blockedServers *MutexArray[string] = nil
|
||||||
|
ipAddressRegex *regexp.Regexp = regexp.MustCompile(`^\d{1,3}(\.\d{1,3}){3}$`)
|
||||||
)
|
)
|
||||||
|
|
||||||
// MutexArray is a thread-safe array for storing and retrieving values.
|
// MutexArray is a thread-safe array for storing and retrieving values.
|
||||||
|
|||||||
Reference in New Issue
Block a user