-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
39 lines (33 loc) · 882 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
package main
import (
"github.com/Traineau/gomail/database"
"github.com/Traineau/gomail/email"
"github.com/Traineau/gomail/router"
"github.com/gorilla/handlers"
"log"
"net/http"
"os"
"strings"
)
func main() {
err := database.Connect()
if err != nil {
log.Fatalf("could not connect to db: %v", err)
}
err = email.ConnectToRabbitMQ()
if err != nil {
log.Fatalf("could not connect to RabbitMQ: %v", err)
}
router := router.NewRouter()
log.Print("\nServer started on port 8080")
// start listening to port 8080
err = http.ListenAndServe(
":8080",
handlers.CORS(
// Allowed origins are specified in docker-compose.yaml
handlers.AllowedOrigins(strings.Split(os.Getenv("CORS_ALLOWED_ORIGINS"), ",")),
handlers.AllowedHeaders([]string{"Content-Type"}),
handlers.AllowedMethods([]string{"GET", "HEAD", "POST", "PUT", "DELETE"}),
)(router),
)
}