Add unique addresses to Redis

This commit is contained in:
Jacob Gunther
2022-10-22 18:31:21 -05:00
parent d0c0567b0d
commit 3284922faf
3 changed files with 15 additions and 1 deletions

View File

@@ -1,8 +1,10 @@
package main
import (
"fmt"
"net/http"
"strconv"
"time"
"github.com/gofiber/fiber/v2"
"github.com/mcstatus-io/shared/status"
@@ -29,6 +31,10 @@ func JavaStatusHandler(ctx *fiber.Ctx) error {
return ctx.Status(http.StatusBadRequest).SendString("Invalid address value")
}
if err = r.Set(fmt.Sprintf("unique:%s-%d", host, port), time.Now(), 0); err != nil {
return err
}
response, expiresAt, err := status.GetJavaStatus(r, host, port, config.Cache.JavaCacheDuration)
if err != nil {
@@ -49,6 +55,10 @@ func BedrockStatusHandler(ctx *fiber.Ctx) error {
return ctx.Status(http.StatusBadRequest).SendString("Invalid address value")
}
if err = r.Set(fmt.Sprintf("unique:%s-%d", host, port), time.Now(), 0); err != nil {
return err
}
response, expiresAt, err := status.GetBedrockStatus(r, host, port, config.Cache.BedrockCacheDuration)
if err != nil {