-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
57 lines (53 loc) · 1.29 KB
/
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
50
51
52
53
54
55
56
57
package main
import (
"net/http"
"time"
"github.com/charisworks/charisworks-service-go/handler"
"github.com/charisworks/charisworks-service-go/meilisearch"
"github.com/gin-contrib/cors"
"github.com/gin-gonic/gin"
)
func main() {
r := gin.Default()
gin.SetMode(gin.ReleaseMode)
CORS(r)
h := handler.NewHandler(r)
meilisearch.InitMeilisearch()
h.SetupStripeEventHandler()
h.SetupStrapiEventHandler()
h.SetupCheckoutEventHandler()
h.SetupItmeHandler()
http.ListenAndServe(":8080", r)
}
func CORS(r *gin.Engine) {
r.Use(cors.New(cors.Config{
// アクセス許可するオリジン
AllowOrigins: []string{
"https://beta.charis.works",
"https://search.charis.works",
"http://next:3000",
"https://api.charis.works",
"https://charis.works",
},
// アクセス許可するHTTPメソッド
AllowMethods: []string{
"POST",
"GET",
"OPTIONS",
"PATCH",
"DELETE",
},
// 許可するHTTPリクエストヘッダ
AllowHeaders: []string{
"Content-Type",
"Access-Control-Allow-Origin",
"Access-Control-Allow-Headers",
"Authorization",
"Access-Control-Allow-Credentials",
},
// cookieなどの情報を必要とするかどうか
AllowCredentials: true,
// preflightリクエストの結果をキャッシュする時間
MaxAge: 24 * time.Hour,
}))
}