Move assets to its own folder
This commit is contained in:
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 (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"main/src/assets"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strconv"
|
"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.
|
// FaviconHandler serves the favicon.ico file to any users that visit the API using a browser.
|
||||||
func FaviconHandler(ctx *fiber.Ctx) error {
|
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.
|
// 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.
|
// DefaultIconHandler returns the default server icon.
|
||||||
func DefaultIconHandler(ctx *fiber.Ctx) error {
|
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.
|
// NotFoundHandler handles requests to routes that do not exist and returns a 404 Not Found status.
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import (
|
|||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"main/src/assets"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
@@ -210,7 +211,7 @@ func GetServerIcon(host string, port uint16) ([]byte, time.Duration, error) {
|
|||||||
return cache, ttl, err
|
return cache, ttl, err
|
||||||
}
|
}
|
||||||
|
|
||||||
icon := defaultIconBytes
|
icon := assets.DefaultIcon
|
||||||
|
|
||||||
status, err := mcutil.Status(host, port)
|
status, err := mcutil.Status(host, port)
|
||||||
|
|
||||||
|
|||||||
@@ -16,10 +16,6 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
//go:embed icon.png
|
|
||||||
defaultIconBytes []byte
|
|
||||||
//go:embed favicon.ico
|
|
||||||
favicon []byte
|
|
||||||
blockedServers *MutexArray[string] = nil
|
blockedServers *MutexArray[string] = nil
|
||||||
ipAddressRegex *regexp.Regexp = regexp.MustCompile(`^\d{1,3}(\.\d{1,3}){3}$`)
|
ipAddressRegex *regexp.Regexp = regexp.MustCompile(`^\d{1,3}(\.\d{1,3}){3}$`)
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user