-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
49 lines (43 loc) · 969 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
48
49
package main
import (
"net/http"
"time"
"github.com/kohbanye/storage/config"
"github.com/kohbanye/storage/model"
"github.com/kohbanye/storage/router"
"github.com/labstack/echo/v4"
"github.com/labstack/echo/v4/middleware"
)
func main() {
e := echo.New()
config.Init()
time.Sleep(3 * time.Second) // wait for DB container to start
rep, err := model.Init()
if err != nil {
panic(err)
}
router.Init(e, rep)
e.Use(middleware.CORSWithConfig(middleware.CORSConfig{
AllowOrigins: []string{"http://localhost:3000"},
AllowHeaders: []string{
echo.HeaderAccessControlAllowHeaders,
echo.HeaderContentType,
echo.HeaderContentLength,
echo.HeaderAcceptEncoding,
echo.HeaderXCSRFToken,
echo.HeaderAuthorization,
},
AllowMethods: []string{
http.MethodGet,
http.MethodPut,
http.MethodPatch,
http.MethodPost,
http.MethodDelete,
},
}))
e.Use(middleware.Logger())
err = e.Start(":8000")
if err != nil {
panic(err)
}
}