forked from siddhantmadhur/ocelot-media-server
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.go
40 lines (30 loc) · 781 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
package main
import (
"fmt"
"log"
"ocelot/config"
"os"
"github.com/labstack/echo/v4"
"github.com/labstack/echo/v4/middleware"
)
func main() {
err := runSqliteInit()
if err != nil {
log.Fatal("There was an error in connecting to the sqlite file: " + err.Error())
os.Exit(1)
}
var config config.Config
err = config.Read()
if err != nil {
log.Fatal("[ERROR]: Config could not be read. " + 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)
e.Logger.Fatal(e.Start(fmt.Sprintf(":%d", config.Port)))
}