-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.go
More file actions
40 lines (29 loc) · 1.16 KB
/
Copy pathapp.go
File metadata and controls
40 lines (29 loc) · 1.16 KB
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 (
"log"
"net/http"
"test/helper"
"test/routes"
"github.com/gorilla/handlers"
)
func main() {
defer func() {
if err := recover(); err != nil {
log.Println("dispatchRequest :: panic :: ", err)
}
}()
r := routes.NewRouter()
r.Use(func(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
r.Body = http.MaxBytesReader(w, r.Body, 50*1024*1024)
next.ServeHTTP(w, r)
})
})
origins := handlers.AllowedOrigins([]string{"https://penitenciarios.com", "https://www.penitenciarios.com", "https://dev.penitenciarios.com", "https://www.dev.penitenciarios.com", "http://localhost:3000", "http://127.0.0.1:3000"})
allowedHeaders := handlers.AllowedHeaders([]string{"X-Requested-With", "Content-Type", "Authorization"})
allowedMethods := handlers.AllowedMethods([]string{"GET", "POST", "PUT", "HEAD", "OPTIONS", "DELETE"})
corsOptions := handlers.CORS(origins, allowedHeaders, allowedMethods)
// updateData.UpdateData() // Funcion para actuaizar los datos de todos los usuarios
config_vars := helper.GetConfigVars()
http.ListenAndServe(":"+config_vars["LISTEN_PORT"], corsOptions(r))
}