forked from AndreiD/arweave-ipfs-bridge
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathrouter.go
41 lines (28 loc) · 918 Bytes
/
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
package main
import (
"aif/handlers"
"net/http"
"github.com/gin-gonic/gin"
)
// InitializeRouter initialises all the routes in the app
func InitializeRouter() {
api := router.Group("/api")
// pong
api.GET("/ping", handlers.Ping)
// get a file from IPFS by it's hash
api.GET("/ipfs", handlers.GetFromIPFS)
// get a file from AR by it's transaction ID
api.GET("/arweave", handlers.GetFromArweave)
// transfer a file from IFPS to AR
api.POST("/transfer", handlers.TransferIPFSToArweave)
// transfer a file directly to AR
api.POST("/transfer_arweave", handlers.TransferToArweave)
// checks if a tx has been mined
api.GET("/check_tx_arweave", handlers.CheckTxArweave)
// check the balance of AR tokens
api.GET("/balance", handlers.GetBalance)
// In case no route is found
router.NoRoute(func(c *gin.Context) {
c.JSON(http.StatusBadRequest, gin.H{"error": "api endpoint not found"})
})
}