-
Notifications
You must be signed in to change notification settings - Fork 1
/
server.go
44 lines (35 loc) · 916 Bytes
/
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
package main
import (
"fmt"
"log"
"ocelot/config"
"os"
"github.com/labstack/echo/v4"
"github.com/labstack/echo/v4/middleware"
)
func main() {
var cfg config.Config
if os.Getenv("PERSISTENT_DATA") != "" {
cfg.PersistentDir = os.Getenv("PERSISTENT_DATA")
} else {
cfg.PersistentDir = "/data"
}
err := cfg.Read()
if err != nil {
log.Fatal("[ERROR]: Config could not be read. " + err.Error())
os.Exit(1)
}
err = runSqliteInit(&cfg)
if err != nil {
log.Fatal("There was an error in connecting to the sqlite file: " + err.Error())
os.Exit(1)
}
e := echo.New()
e.Use(middleware.CORSWithConfig(middleware.CORSConfig{
AllowOrigins: []string{"http://localhost:5173"},
//AllowMethods: []string{"POST", "GET", "UPDATE", "DELETE"},
AllowHeaders: []string{"Client-Name", "Content-Type", "Authorization"},
}))
handler(e, &cfg)
e.Logger.Fatal(e.Start(fmt.Sprintf(":%d", cfg.Port)))
}