-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
33 lines (29 loc) · 1.01 KB
/
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 (
"JSMPJ_jwt_final/app"
"JSMPJ_jwt_final/validate"
"log"
"net/http"
"JSMPJ_jwt_final/keyinit"
"JSMPJ_jwt_final/models"
"github.com/gorilla/handlers"
"github.com/gorilla/mux"
)
func StartServer() {
newRouter := mux.NewRouter()
origins := handlers.AllowedOrigins([]string{"*"})
headers := handlers.AllowedHeaders([]string{"Accept", "Content-Type", "Content-Length", "Accept-Encoding", "X-CSRF-Token", "Authorization"})
methods := handlers.AllowedMethods([]string{"GET", "PUT", "POST", "DELETE"})
newRouter.HandleFunc("/login", models.LoginHandler).Methods("POST")
newRouter.HandleFunc("/sawdetails", models.SawDetail).Methods("GET")
newRouter.HandleFunc("/resource/", validate.Validate).Methods("GET")
newRouter.HandleFunc("/check/", validate.Check).Methods("GET")
newRouter.Use(app.JwtAuthentication)
log.Println("Now listening...")
log.Fatal(http.ListenAndServe(":8001", handlers.CORS(origins, methods, headers)(newRouter)))
}
func main() {
keyinit.InitKeys()
models.DBinit()
StartServer()
}