forked from aureleoules/core
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
41 lines (33 loc) · 846 Bytes
/
main.go
File metadata and controls
41 lines (33 loc) · 846 Bytes
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
package main
import (
"log"
"net/http"
"os"
"github.com/backpulse/core/database"
"github.com/backpulse/core/routes"
"github.com/backpulse/core/utils"
"github.com/rs/cors"
)
func main() {
log.SetFlags(log.LstdFlags | log.Lshortfile)
config := utils.GetConfig()
database.Connect(config.URI, config.Database)
utils.InitStripe()
r := routes.NewRouter()
c := cors.New(cors.Options{
AllowedOrigins: []string{"*"},
AllowedHeaders: []string{"Access-Control-Allow-Origin", "origin", "X-Requested-With", "Authorization", "Content-Type", "Language"},
AllowedMethods: []string{"DELETE", "POST", "GET", "PUT"},
})
handler := c.Handler(r)
var port string
if os.Getenv("PORT") == "" {
port = ":8000"
} else {
port = ":" + os.Getenv("PORT")
}
err := http.ListenAndServe(port, handler)
if err != nil {
log.Fatal(err)
}
}