-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
36 lines (30 loc) · 981 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
34
35
36
package main
import (
"./app"
"./controllers"
"fmt"
"github.com/gorilla/mux"
"net/http"
"os"
)
func main(){
router:= mux.NewRouter()
router.Use(app.JwtAuthentication)
router.HandleFunc("/api/user/new", controllers.CreateAccount).Methods("POST")
router.HandleFunc("/api/user/login", controllers.Authenticate).Methods("POST")
router.HandleFunc("/api/me/contacts", controllers.GetContactsFor).Methods("GET")
router.HandleFunc("/api/me/contacts", controllers.CreateContact).Methods("POST")
router.HandleFunc("/api/me/addresses", controllers.GetAddresses).Methods("GET")
router.HandleFunc("/api/me/addresses", controllers.CreateAddresses).Methods("POST")
router.HandleFunc("/api/me/user", controllers.GetUser).Methods("GET")
router.HandleFunc("/api/me/user", controllers.CreateUser).Methods("POST")
port:= os.Getenv("PORT")
if(port == ""){
port = "8000"
}
fmt.Println(port)
err:=http.ListenAndServe(":" + port, router)
if err != nil{
fmt.Print(err)
}
}