Move assets to its own folder
This commit is contained in:
parent
17948164fd
commit
d814d6bd05
10
src/assets/assets.go
Normal file
10
src/assets/assets.go
Normal file
@ -0,0 +1,10 @@
|
||||
package assets
|
||||
|
||||
import _ "embed"
|
||||
|
||||
var (
|
||||
//go:embed icon.png
|
||||
DefaultIcon []byte
|
||||
//go:embed favicon.ico
|
||||
Favicon []byte
|
||||
)
|
||||
|
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 13 KiB |
|
Before Width: | Height: | Size: 3.1 KiB After Width: | Height: | Size: 3.1 KiB |
@ -2,6 +2,7 @@ package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"main/src/assets"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
@ -25,7 +26,7 @@ func PingHandler(ctx *fiber.Ctx) error {
|
||||
|
||||
// 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)
|
||||
return ctx.Type("ico").Send(assets.Favicon)
|
||||
}
|
||||
|
||||
// JavaStatusHandler returns the status of the Java edition Minecraft server specified in the address parameter.
|
||||
@ -107,7 +108,7 @@ func IconHandler(ctx *fiber.Ctx) error {
|
||||
|
||||
// DefaultIconHandler returns the default server icon.
|
||||
func DefaultIconHandler(ctx *fiber.Ctx) error {
|
||||
return ctx.Type("png").Send(defaultIconBytes)
|
||||
return ctx.Type("png").Send(assets.DefaultIcon)
|
||||
}
|
||||
|
||||
// NotFoundHandler handles requests to routes that do not exist and returns a 404 Not Found status.
|
||||
|
||||
@ -4,6 +4,7 @@ import (
|
||||
"encoding/base64"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"main/src/assets"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync"
|
||||
@ -210,7 +211,7 @@ func GetServerIcon(host string, port uint16) ([]byte, time.Duration, error) {
|
||||
return cache, ttl, err
|
||||
}
|
||||
|
||||
icon := defaultIconBytes
|
||||
icon := assets.DefaultIcon
|
||||
|
||||
status, err := mcutil.Status(host, port)
|
||||
|
||||
|
||||
@ -16,10 +16,6 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
//go:embed icon.png
|
||||
defaultIconBytes []byte
|
||||
//go:embed favicon.ico
|
||||
favicon []byte
|
||||
blockedServers *MutexArray[string] = nil
|
||||
ipAddressRegex *regexp.Regexp = regexp.MustCompile(`^\d{1,3}(\.\d{1,3}){3}$`)
|
||||
)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user