-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
44 lines (37 loc) · 863 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
package main
import (
"dagora_galaxe_querys/clients"
"dagora_galaxe_querys/routes"
"log"
"net/http"
"os"
"github.com/gorilla/mux"
"github.com/joho/godotenv"
"github.com/rs/cors"
)
func main() {
_ = godotenv.Load()
r := mux.NewRouter()
clts, err := clients.InitClients()
if err != nil {
log.Fatal(err)
os.Exit(1)
}
routes.HandleRoutes(r, clts)
handler := cors.New(cors.Options{
AllowedOrigins: []string{"https://galxe.com"}, // Adjust this to your needs
AllowedMethods: []string{"GET", "POST", "PUT", "DELETE"},
AllowedHeaders: []string{"Content-Type", "Origin", "Accept", "*"},
}).Handler(r)
port := os.Getenv("PORT")
if port == "" {
log.Fatalf("PORT must be set")
os.Exit(1)
}
log.Println("Server running on port " + port)
err = http.ListenAndServe(":"+port, handler)
if err != nil {
log.Fatal(err)
os.Exit(1)
}
}