-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
62 lines (43 loc) · 1.8 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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
package main
import (
"net/http"
"batuhand.com/api/controllers"
"github.com/gorilla/mux"
_ "github.com/lib/pq"
)
func main() {
rootName := "/api"
router := mux.NewRouter()
router.HandleFunc("/ws", controllers.WsEndpoint)
// ------------------------- USER ENDPOINTS -------------------------
// Get all users
// Method: GET - /get_users/
router.HandleFunc(rootName+"/user/get_users/", controllers.GetAllUsers).Methods("GET")
// Get user by id
// Method: GET - /user/%id
router.HandleFunc(rootName+"/user/get_user/{id}", controllers.GetUser).Methods("GET")
// Update user by id
// Method: PUT - /user/%id
router.HandleFunc(rootName+"/user/update_user/{id}", controllers.UpdateUser).Methods("PUT")
// Delete user by id
// Method: DELETE - /user/%id
router.HandleFunc(rootName+"/user/delete_user/{id}", controllers.DeleteUser).Methods("DELETE")
// New user
// Method: POST - /create_user/
router.HandleFunc(rootName+"/user/create_user/", controllers.CreateUser).Methods("POST")
// ------------------------- TRANSACTION ENDPOINTS -------------------------
// Get all transactions
// Method: GET - /get_transactions/
router.HandleFunc(rootName+"/transaction/get_transactions/", controllers.GetAllTransactions).Methods("GET")
// New transaction
// Method: POST - /send_coin/
router.HandleFunc(rootName+"/transaction/send_coin/", controllers.SendCoin).Methods("POST")
// Get wallet currency
// Method: GET - /get_wallet_currency/
router.HandleFunc(rootName+"/transaction/get_wallet_currency/{wallet_id}", controllers.GetCurrency).Methods("GET")
// ------------------------- MINING ENDPOINTS -------------------------
// Mine confirm
// Method: POST - /get_wallet_currency/
router.HandleFunc(rootName+"/mine/upload/", controllers.UploadHash).Methods("POST")
http.ListenAndServe(":8080", router)
}