Make X-Prober-Api-Key as constant

This commit is contained in:
ditatompel 2024-05-30 13:40:57 +07:00
parent c6e0ce751e
commit 130cd06dc4
No known key found for this signature in database
GPG key ID: 31D3D06D77950979
3 changed files with 5 additions and 3 deletions

View file

@ -99,7 +99,7 @@ func (p *proberClient) fetchJob() (monero.Node, error) {
if err != nil { if err != nil {
return node, err return node, err
} }
req.Header.Add("X-Prober-Api-Key", p.config.ApiKey) req.Header.Add(monero.ProberAPIKey, p.config.ApiKey)
req.Header.Set("User-Agent", RPCUserAgent) req.Header.Set("User-Agent", RPCUserAgent)
client := &http.Client{} client := &http.Client{}
@ -285,7 +285,7 @@ func (p *proberClient) reportResult(node monero.Node, tookTime float64) error {
if err != nil { if err != nil {
return err return err
} }
req.Header.Add("X-Prober-Api-Key", p.config.ApiKey) req.Header.Add(monero.ProberAPIKey, p.config.ApiKey)
req.Header.Set("Content-Type", "application/json; charset=UTF-8") req.Header.Set("Content-Type", "application/json; charset=UTF-8")
req.Header.Set("User-Agent", RPCUserAgent) req.Header.Set("User-Agent", RPCUserAgent)

View file

@ -7,7 +7,7 @@ import (
) )
func CheckProber(c *fiber.Ctx) error { func CheckProber(c *fiber.Ctx) error {
key := c.Get("X-Prober-Api-Key") key := c.Get(monero.ProberAPIKey)
if key == "" { if key == "" {
return c.Status(fiber.StatusUnauthorized).JSON(fiber.Map{ return c.Status(fiber.StatusUnauthorized).JSON(fiber.Map{
"status": "error", "status": "error",

View file

@ -9,6 +9,8 @@ import (
"github.com/google/uuid" "github.com/google/uuid"
) )
const ProberAPIKey = "X-Prober-Api-Key" // HTTP header key
type ProberRepository interface { type ProberRepository interface {
Add(name string) (Prober, error) Add(name string) (Prober, error)
Edit(id int, name string) error Edit(id int, name string) error