-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
37 lines (27 loc) · 863 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
37
package main
import (
"fmt"
"net/http"
"os"
"rest-api/app"
"rest-api/controllers"
"github.com/gorilla/mux"
)
func main() {
router := mux.NewRouter()
router.HandleFunc("/api/user/new", controllers.CreateAccount).Methods("POST")
router.HandleFunc("/api/user/login", controllers.Authenticate).Methods("POST")
router.HandleFunc("/api/user/operation/{id}", controllers.Transaction).Methods("POST")
router.HandleFunc("/api/operation/user/{id}", controllers.GetUser).Methods("GET")
router.HandleFunc("/api/operation/date/{operation_date}", controllers.GetDate).Methods("GET")
router.Use(app.JwtAuthentication)
port := os.Getenv("PORT")
if port == "" {
port = "8000" //localhost
}
fmt.Println(port)
err := http.ListenAndServe(":"+port, router) //localhost:8000/api
if err != nil {
fmt.Print(err)
}
}