diff --git a/handler/response.go b/handler/response.go index b7aafc8..2849a11 100644 --- a/handler/response.go +++ b/handler/response.go @@ -7,7 +7,8 @@ import ( "github.com/gofiber/fiber/v2" ) -func MoneroNode(c *fiber.Ctx) error { +// Returns a single node information based on `id` query param +func Node(c *fiber.Ctx) error { nodeId, err := c.ParamsInt("id", 0) if err != nil { return c.Status(fiber.StatusUnprocessableEntity).JSON(fiber.Map{ @@ -42,7 +43,8 @@ func MoneroNode(c *fiber.Ctx) error { }) } -func MoneroNodes(c *fiber.Ctx) error { +// Returns a list of nodes +func Nodes(c *fiber.Ctx) error { moneroRepo := monero.New() query := monero.QueryNodes{ RowsPerPage: c.QueryInt("limit", 10), diff --git a/handler/routes.go b/handler/routes.go index 1be4a41..3535ea6 100644 --- a/handler/routes.go +++ b/handler/routes.go @@ -4,15 +4,19 @@ import ( "github.com/gofiber/fiber/v2" ) +// V1 API routes func V1Api(app *fiber.App) { v1 := app.Group("/api/v1") - v1.Get("/nodes", MoneroNodes) + // these routes are public, they don't require a prober api key + v1.Get("/nodes", Nodes) v1.Post("/nodes", AddNode) - v1.Get("/nodes/id/:id", MoneroNode) + v1.Get("/nodes/id/:id", Node) v1.Get("/nodes/logs", ProbeLogs) v1.Get("/fees", NetFees) v1.Get("/countries", Countries) + + // these routes are for prober, they require a prober api key v1.Get("/job", CheckProber, GiveJob) v1.Post("/job", CheckProber, ProcessJob) }