-
Notifications
You must be signed in to change notification settings - Fork 0
/
rest.go
36 lines (30 loc) · 1.15 KB
/
rest.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 rest
import (
"github.com/gorilla/mux"
"github.com/creatachain/creata-sdk/client"
"github.com/creatachain/creata-sdk/client/rest"
)
// REST query and parameter values
const (
MethodGet = "GET"
)
// RegisterRoutes registers the auth module REST routes.
func RegisterRoutes(clientCtx client.Context, rtr *mux.Router, storeName string) {
r := rest.WithHTTPDeprecationHeaders(rtr)
r.HandleFunc(
"/auth/accounts/{address}", QueryAccountRequestHandlerFn(storeName, clientCtx),
).Methods(MethodGet)
r.HandleFunc(
"/auth/params",
queryParamsHandler(clientCtx),
).Methods(MethodGet)
}
// RegisterTxRoutes registers all transaction routes on the provided router.
func RegisterTxRoutes(clientCtx client.Context, rtr *mux.Router) {
r := rest.WithHTTPDeprecationHeaders(rtr)
r.HandleFunc("/txs/{hash}", QueryTxRequestHandlerFn(clientCtx)).Methods("GET")
r.HandleFunc("/txs", QueryTxsRequestHandlerFn(clientCtx)).Methods("GET")
r.HandleFunc("/txs", BroadcastTxRequest(clientCtx)).Methods("POST")
r.HandleFunc("/txs/encode", EncodeTxRequestHandlerFn(clientCtx)).Methods("POST")
r.HandleFunc("/txs/decode", DecodeTxRequestHandlerFn(clientCtx)).Methods("POST")
}