-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
36 lines (30 loc) · 883 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
package main
import (
"github.com/MikelSot/melody/database"
"github.com/MikelSot/melody/infrastructure/authorization"
"github.com/MikelSot/melody/infrastructure/routes"
"github.com/gorilla/mux"
"github.com/rs/cors"
"log"
"net/http"
"os"
)
func main() {
pool := database.Database()
authorization.NewAuthorization(authorization.NewLoaJWTdFile()).LoadJwtFile(
"certificates/app.rsa",
"certificates/app.rsa.public",
)
r := mux.NewRouter().StrictSlash(true)
router := routes.NewRouter(r, pool, authorization.NewMyJWT())
router.User()
router.Chat()
router.ChatUser()
port := os.Getenv("PORT_SERVER")
handler := cors.New(cors.Options{
AllowedOrigins: []string{"*"},
AllowedMethods: []string{http.MethodGet, http.MethodPost, http.MethodDelete, http.MethodPut},
AllowCredentials: true,
}).Handler(r)
log.Fatal(http.ListenAndServe(":"+port, handler))
}