summaryrefslogtreecommitdiff
path: root/api/server.go
blob: 32e3202423e49ac98c9cf92dd194b8e8f3f27720 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
package api

import (
	"github.com/gofiber/fiber/v2"
	"github.com/keuin/slbr/api/agent"
)

func StartServer(addr string, a agent.Agent) error {
	app := fiber.New()

	app.Get("/", func(c *fiber.Ctx) error {
		return c.SendString("Hello, World!")
	})

	app.Get("/tasks", func(c *fiber.Ctx) error {
		return c.JSON(a.GetTasks())
	})

	return app.Listen(addr)
}