-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
40 lines (32 loc) · 899 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
package main
import (
"covid-19API/rutas"
"fmt"
"net/http"
"os"
"github.com/rs/cors"
)
func main() {
// Rutas
routes := rutas.Routes()
// Server lectura del puerto
port := os.Getenv("PORT")
if port == "" {
port = "8000" //localhost
}
// CORS Configuracion
c := cors.New(cors.Options{
AllowedOrigins: []string{"http://localhost:4200", "*", "http://localhost:3000"},
AllowCredentials: true,
AllowedMethods: []string{"POST", "GET", "OPTIONS", "PUT", "DELETE", "PATCH"},
AllowedHeaders: []string{"Accept", "Content-Type", "Origin", "X-Requested-With", "Content-Length", "Accept-Encoding", "Cache-Control", "Authorization"},
// Enable Debugging for testing, consider disabling in production
Debug: true,
})
handler := c.Handler(routes)
// Server listening
err := http.ListenAndServe(":"+port, handler) //Launch the app.
if err != nil {
fmt.Print(err)
}
}