-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrouter.go
61 lines (51 loc) · 1.75 KB
/
router.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
package main
import (
"os"
"strings"
"github.com/gin-contrib/pprof"
"github.com/gin-gonic/gin"
)
func init() {
if strings.ToLower(os.Getenv("DEBUG")) == "true" {
gin.SetMode(gin.DebugMode)
} else {
gin.SetMode(gin.ReleaseMode)
}
}
func configureRouter() *gin.Engine {
router := gin.New()
router.Use(gin.Recovery())
if strings.ToLower(os.Getenv("DEBUG")) == "true" {
router.Use(gin.Logger())
pprof.Register(router)
}
// routes
xmr := router.Group("/xmr")
{
xmr.GET("/notify/:txid", routes.CheckAPIKey, routes.XMRNotify)
xmr.POST("/createaccount", routes.CheckAPIKey, routes.CreateXMRAccount)
xmr.POST("/createaddress", routes.CheckAPIKey, routes.CreateXMRAddress)
xmr.POST("/getbalance", routes.CheckAPIKey, routes.GetXMRBalance)
xmr.POST("/transfer", routes.CheckAPIKey, routes.TransferXMR)
}
btc := router.Group("/btc")
{
btc.GET("/balance", routes.CheckAPIKey, routes.GetBalance)
btc.POST("/createaccount", routes.CheckAPIKey, routes.CreateAccount)
btc.POST("/listtransactions", routes.CheckAPIKey, routes.ListTransactions)
btc.POST("/sendtoaddress", routes.CheckAPIKey, routes.SendToAddress)
btc.POST("/sendfrom", routes.CheckAPIKey, routes.SendFrom)
btc.POST("/sendmany", routes.CheckAPIKey, routes.SendMany)
btc.POST("/move", routes.CheckAPIKey, routes.Move)
btc.POST("/getaccountaddress", routes.CheckAPIKey, routes.GetAccountAddress)
btc.POST("/addmultisig", routes.CheckAPIKey, routes.AddMultisigAddress)
btc.POST("/submit_pubkey", routes.CheckAPIKey, routes.SubmitPublicKey)
btc.POST("/unlock", routes.CheckAPIKey, routes.UnlockWallet)
}
api := router.Group("/api")
{
api.POST("/revoke", routes.CheckAPIKey, routes.RevokeAPIKey)
api.GET("/health", routes.CheckAPIKey, routes.HealthCheck)
}
return router
}