Add favicon route
This commit is contained in:
parent
7ecc250f03
commit
17948164fd
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() {
|
||||
app.Get("/ping", PingHandler)
|
||||
app.Get("/favicon.ico", FaviconHandler)
|
||||
app.Get("/status/java/:address", JavaStatusHandler)
|
||||
app.Get("/status/bedrock/:address", BedrockStatusHandler)
|
||||
app.Get("/icon", DefaultIconHandler)
|
||||
@ -22,6 +23,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)
|
||||
}
|
||||
|
||||
// JavaStatusHandler returns the status of the Java edition Minecraft server specified in the address parameter.
|
||||
func JavaStatusHandler(ctx *fiber.Ctx) error {
|
||||
host, port, err := ParseAddress(ctx.Params("address"), 25565)
|
||||
|
||||
@ -18,8 +18,10 @@ import (
|
||||
var (
|
||||
//go:embed icon.png
|
||||
defaultIconBytes []byte
|
||||
blockedServers *MutexArray[string] = nil
|
||||
ipAddressRegex *regexp.Regexp = regexp.MustCompile(`^\d{1,3}(\.\d{1,3}){3}$`)
|
||||
//go:embed favicon.ico
|
||||
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.
|
||||
|
||||
Loading…
Reference in New Issue
Block a user