-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.go
52 lines (48 loc) · 1.21 KB
/
server.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
48
49
50
51
52
package main
import (
"embed"
"fmt"
"github.com/Leagueify/api/internal/config"
"github.com/Leagueify/api/internal/endpoints"
"github.com/getsentry/sentry-go"
sentryecho "github.com/getsentry/sentry-go/echo"
"github.com/labstack/echo/v4"
"github.com/labstack/echo/v4/middleware"
)
var (
//go:embed all:internal/web
web embed.FS
webAssetFS = echo.MustSubFS(web, "internal/web/assets")
webDocsFS = echo.MustSubFS(web, "internal/web/docs")
)
func main() {
// Configuration
cfg := config.LoadConfig()
// Echo Initialization
e := echo.New()
// Middleware Config
e.Use(middleware.LoggerWithConfig(middleware.LoggerConfig{
Format: "${time_rfv3339}::${remote_id}::${status}:${method}:${uri}\n",
}))
e.Use(middleware.Recover())
// Sentry Initialization
if cfg.Sentry {
if err := sentry.Init(sentry.ClientOptions{
Dsn: cfg.SentryDSN,
// Adjust TSR in production
TracesSampleRate: cfg.SentryTSR,
}); err != nil {
fmt.Printf("Sentry initialization failed: %v\n", err)
}
e.Use(sentryecho.New(sentryecho.Options{
Repanic: true,
}))
}
// API Docs
e.StaticFS("/api", webDocsFS)
e.StaticFS("/assets", webAssetFS)
// API Routes
api.Routes(e)
// Start Server
e.Logger.Fatal(e.Start(":8888"))
}