-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
38 lines (28 loc) · 1.03 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
package main
import (
"log"
"net/http"
"github.com/gorilla/mux"
_ "github.com/joho/godotenv/autoload"
"github.com/micro-tok/gateway/pkg/auth"
"github.com/micro-tok/gateway/pkg/config"
"github.com/micro-tok/gateway/pkg/video"
"github.com/rs/cors"
)
func main() {
cfg := config.LoadConfig()
r := mux.NewRouter()
c := cors.New(cors.Options{
AllowedOrigins: []string{"http://localhost:3000", "https://*.vercel.app", "http://localhost:3000/", "https://*.vercel.app/", "http://*.kaloyan.tech/", "https://*.kaloyan.tech", "*"},
AllowedMethods: []string{"GET", "POST", "PUT", "DELETE", "OPTIONS"},
AllowedHeaders: []string{"Accept", "Content-Type", "Content-Length", "Accept-Encoding", "X-CSRF-Token", "Authorization"},
AllowCredentials: true,
})
authSvc := auth.RegisterRouter(r, cfg)
video.RegisterRouter(r, cfg, authSvc.AuthClient)
r.HandleFunc("/health", func(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusOK)
})
handler := c.Handler(r)
log.Fatal(http.ListenAndServe(":"+cfg.Port, handler))
}