-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
36 lines (28 loc) · 1.22 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
34
35
36
package main
import (
"net/http"
"github.com/gorilla/mux"
"github.com/juanmaescudero/go-ms-auth/db"
"github.com/juanmaescudero/go-ms-auth/models"
"github.com/juanmaescudero/go-ms-auth/routes"
)
func main() {
db.DBConnnection()
db.DB.AutoMigrate(models.App{})
db.DB.AutoMigrate(models.User{})
r := mux.NewRouter()
r.HandleFunc("/users", routes.GetUsersHandler).Methods("GET")
r.HandleFunc("/users/{id}", routes.GetUserHandler).Methods("GET")
r.HandleFunc("/users/{id}", routes.DeleteUserHandler).Methods("DELETE")
r.HandleFunc("/users/{id}", routes.PutUserHandler).Methods("PUT")
r.HandleFunc("/users/login", routes.LoginHandler).Methods("POST")
r.HandleFunc("/users/register", routes.CreateUsersHandler).Methods("POST")
r.HandleFunc("/users/confirm", routes.ConfirmUserHandler).Methods("POST")
r.HandleFunc("/verify", routes.VerifyJWT).Methods("POST")
r.HandleFunc("/apps", routes.GetAppsHandler).Methods("GET")
r.HandleFunc("/apps/{id}", routes.GetAppHandler).Methods("GET")
r.HandleFunc("/apps/{id}", routes.DeleteAppHandler).Methods("DELETE")
r.HandleFunc("/apps/{id}", routes.PutAppHandler).Methods("PUT")
r.HandleFunc("/apps/register", routes.CreateAppHandler).Methods("POST")
http.ListenAndServe(":3000", r)
}