-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
30 lines (22 loc) · 804 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
package main
import (
"net/http"
"fmt"
"go-api-jwt-v2/routers"
"go-api-jwt-v2/settings"
"go-api-jwt-v2/repository"
"github.com/gorilla/handlers"
"github.com/codegangsta/negroni"
)
func main() {
allowedOrigins := handlers.AllowedOrigins([]string{"*"})
allowedMethods := handlers.AllowedMethods([]string{"GET", "HEAD", "POST", "PUT", "DELETE", "OPTIONS"})
allowedHeaders := handlers.AllowedHeaders([]string{"Accept", "Content-Type", "Content-Length", "Accept-Encoding", "X-CSRF-Token", "Authorization"})
settings.Init()
repository.InitDatabase()
router := routers.InitRoutes()
n := negroni.Classic()
n.UseHandler(router)
connection := fmt.Sprintf(":%s", settings.Get().ServerPort)
http.ListenAndServe(connection, handlers.CORS(allowedHeaders, allowedOrigins, allowedMethods)(n))
}