mirror of
https://github.com/ditatompel/xmr-remote-nodes.git
synced 2024-12-23 20:19:28 +00:00
38320bc316
Also rename ProbersQueryParams to QueryProbers
30 lines
591 B
Go
30 lines
591 B
Go
package handler
|
|
|
|
import (
|
|
"xmr-remote-nodes/internal/monero"
|
|
|
|
"github.com/gofiber/fiber/v2"
|
|
)
|
|
|
|
func CheckProber(c *fiber.Ctx) error {
|
|
key := c.Get("X-Prober-Api-Key")
|
|
if key == "" {
|
|
return c.Status(fiber.StatusUnauthorized).JSON(fiber.Map{
|
|
"status": "error",
|
|
"message": "Unauthorized",
|
|
"data": nil,
|
|
})
|
|
}
|
|
|
|
prober, err := monero.NewProber().CheckApi(key)
|
|
if err != nil {
|
|
return c.Status(fiber.StatusUnauthorized).JSON(fiber.Map{
|
|
"status": "error",
|
|
"message": "No API key match",
|
|
"data": nil,
|
|
})
|
|
}
|
|
|
|
c.Locals("prober_id", prober.Id)
|
|
return c.Next()
|
|
}
|