-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
36 lines (30 loc) · 940 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package main
import (
"github.com/cnumr/ecoindex-bff/config"
"github.com/cnumr/ecoindex-bff/handler"
"github.com/goccy/go-json"
"github.com/gofiber/fiber/v2"
)
func main() {
config.ENV = config.GetEnvironment()
config.CACHE = config.GetCache()
config.MINIFIER = config.GetMinifier()
app := *fiber.New(fiber.Config{
JSONEncoder: json.Marshal,
JSONDecoder: json.Unmarshal,
})
config.ConfigureApp(&app)
app.Get("/badge", handler.GetEcoindexBadge)
app.Get("/redirect", handler.GetEcoindexRedirect)
app.Get("/health", func(c *fiber.Ctx) error {
return c.SendString("OK")
})
api := app.Group("/api")
api.Get("/results", handler.GetEcoindexResultsApi)
api.Post("/tasks", handler.CreateTask)
api.Get("/tasks/:id", handler.GetTask)
api.Get("/screenshot/:id", handler.GetScreenshotApi)
api.Get("/hosts/:hostname", handler.GetHost)
api.Get("/ecoindex", handler.ComputeEcoindex)
app.Listen(":" + config.ENV.AppPort)
}