-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
48 lines (36 loc) · 973 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
37
38
39
40
41
42
43
44
45
46
47
package main
import (
"fmt"
"log"
"github.com/gofiber/fiber/v2"
"github.com/gofiber/fiber/v2/middleware/cors"
"github.com/gofiber/fiber/v2/middleware/logger"
"tritan.gg/rpki-validator/config"
"tritan.gg/rpki-validator/middleware"
"tritan.gg/rpki-validator/router"
)
func main() {
defer func() {
if r := recover(); r != nil {
fmt.Printf("Recovered from panic: %v", r)
}
}()
app := buildApp()
startServer(app)
}
func buildApp() *fiber.App {
app := fiber.New()
app.Use(logger.New())
app.Use(cors.New())
app.Use(middleware.CustomHeaders())
return app
}
func startServer(app *fiber.App) {
if err := router.NewRouter(app); err != nil {
log.Fatalf("Error setting up routes: %v", err)
}
appConfig := config.AppConfigInstance
if err := app.Listen(appConfig.HTTPPort); err != nil {
log.Fatalf("Error starting server: %v", err)
}
}