update gopkg.lock and fix compile error
This commit is contained in:
parent
d6f6a1f87f
commit
b7f27a0e1f
|
@ -312,6 +312,14 @@
|
|||
pruneopts = "UT"
|
||||
revision = "05ee40e3a273f7245e8777337fc7b46e533a9a92"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:ea0700160aca4ef099f4e06686a665a87691f4248dddd40796925eda2e46bd64"
|
||||
name = "github.com/rakyll/statik"
|
||||
packages = ["fs"]
|
||||
pruneopts = "UT"
|
||||
revision = "aa8a7b1baecd0f31a436bf7956fcdcc609a83035"
|
||||
version = "v0.1.4"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:c4556a44e350b50a490544d9b06e9fba9c286c21d6c0e47f54f3a9214597298c"
|
||||
name = "github.com/rcrowley/go-metrics"
|
||||
|
@ -641,6 +649,7 @@
|
|||
"github.com/mitchellh/go-homedir",
|
||||
"github.com/pelletier/go-toml",
|
||||
"github.com/pkg/errors",
|
||||
"github.com/rakyll/statik/fs",
|
||||
"github.com/spf13/cobra",
|
||||
"github.com/spf13/pflag",
|
||||
"github.com/spf13/viper",
|
||||
|
|
|
@ -45,12 +45,6 @@ func TestKeys(t *testing.T) {
|
|||
cleanup, _, port := InitializeTestLCD(t, 1, []sdk.AccAddress{addr})
|
||||
defer cleanup()
|
||||
|
||||
// recover key
|
||||
res, body := doRecoverKey(t, port, seed)
|
||||
var response keys.KeyOutput
|
||||
err := wire.Cdc.UnmarshalJSON([]byte(body), &response)
|
||||
require.Nil(t, err, body)
|
||||
|
||||
reg, err := regexp.Compile(`([a-z]+ ){12}`)
|
||||
require.Nil(t, err)
|
||||
match := reg.MatchString(seed)
|
||||
|
@ -61,7 +55,7 @@ func TestKeys(t *testing.T) {
|
|||
|
||||
// add key
|
||||
jsonStr := []byte(fmt.Sprintf(`{"name":"%s", "password":"%s", "seed":"%s"}`, newName, newPassword, seed))
|
||||
res, body = Request(t, port, "POST", "/keys", jsonStr)
|
||||
res, body := Request(t, port, "POST", "/keys", jsonStr)
|
||||
|
||||
require.Equal(t, http.StatusOK, res.StatusCode, body)
|
||||
var resp keys.KeyOutput
|
||||
|
@ -80,7 +74,7 @@ func TestKeys(t *testing.T) {
|
|||
// existing keys
|
||||
res, body = Request(t, port, "GET", "/keys", nil)
|
||||
require.Equal(t, http.StatusOK, res.StatusCode, body)
|
||||
var m [3]keys.KeyOutput
|
||||
var m [2]keys.KeyOutput
|
||||
err = cdc.UnmarshalJSON([]byte(body), &m)
|
||||
require.Nil(t, err)
|
||||
|
||||
|
|
|
@ -47,6 +47,7 @@ func ServeCommand(cdc *codec.Codec) *cobra.Command {
|
|||
RunE: func(cmd *cobra.Command, args []string) (err error) {
|
||||
listenAddr := viper.GetString(flagListenAddr)
|
||||
handler := createHandler(cdc)
|
||||
registerSwaggerUI(handler)
|
||||
logger := log.NewTMLogger(log.NewSyncWriter(os.Stdout)).With("module", "rest-server")
|
||||
maxOpen := viper.GetInt(flagMaxOpenConnections)
|
||||
sslHosts := viper.GetString(flagSSLHosts)
|
||||
|
@ -129,7 +130,7 @@ func ServeCommand(cdc *codec.Codec) *cobra.Command {
|
|||
return cmd
|
||||
}
|
||||
|
||||
func createHandler(cdc *codec.Codec) http.Handler {
|
||||
func createHandler(cdc *codec.Codec) *mux.Router {
|
||||
r := mux.NewRouter()
|
||||
|
||||
kb, err := keys.GetKeyBase() //XXX
|
||||
|
@ -137,13 +138,6 @@ func createHandler(cdc *codec.Codec) http.Handler {
|
|||
panic(err)
|
||||
}
|
||||
|
||||
statikFS, err := fs.New()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
staticServer := http.FileServer(statikFS)
|
||||
r.PathPrefix("/swagger-ui/").Handler(http.StripPrefix("/swagger-ui/", staticServer))
|
||||
|
||||
cliCtx := context.NewCLIContext().WithCodec(cdc)
|
||||
|
||||
|
||||
|
@ -163,6 +157,15 @@ func createHandler(cdc *codec.Codec) http.Handler {
|
|||
return r
|
||||
}
|
||||
|
||||
func registerSwaggerUI(r *mux.Router) {
|
||||
statikFS, err := fs.New()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
staticServer := http.FileServer(statikFS)
|
||||
r.PathPrefix("/swagger-ui/").Handler(http.StripPrefix("/swagger-ui/", staticServer))
|
||||
}
|
||||
|
||||
func validateCertKeyFiles(certFile, keyFile string) error {
|
||||
if keyFile == "" {
|
||||
return errors.New("a key file is required")
|
||||
|
|
|
@ -178,16 +178,17 @@ paths:
|
|||
$ref: "#/definitions/TxQuery"
|
||||
404:
|
||||
description: Tx not available for provided hash
|
||||
/txs/search:
|
||||
/txs:
|
||||
get:
|
||||
tags:
|
||||
- ICS0
|
||||
summary: Query Tx
|
||||
summary: Search transactions
|
||||
description: Search transactions by tag
|
||||
parameters:
|
||||
- in: query
|
||||
name: tag
|
||||
type: string
|
||||
description: "transaction tag, for instance: sender=`'cosmos1g9ahr6xhht5rmqven628nklxluzyv8z9jqjcmc'`"
|
||||
description: "transaction tag, for instance: sender_bech32=`'cosmos1g9ahr6xhht5rmqven628nklxluzyv8z9jqjcmc'`"
|
||||
required: true
|
||||
- in: query
|
||||
name: page
|
||||
|
@ -206,12 +207,11 @@ paths:
|
|||
$ref: "#/definitions/TxQuery"
|
||||
404:
|
||||
description: Pagination is out of bounds
|
||||
/txs:
|
||||
post:
|
||||
tags:
|
||||
- ICS0
|
||||
summary: broadcast Tx
|
||||
description: broadcast tx
|
||||
description: broadcast tx with tendermint rpc
|
||||
parameters:
|
||||
- in: body
|
||||
name: txBroadcast
|
||||
|
|
|
@ -19,7 +19,7 @@ func AddCommands(cmd *cobra.Command, cdc *codec.Codec) {
|
|||
// register REST routes
|
||||
func RegisterRoutes(cliCtx context.CLIContext, r *mux.Router, cdc *codec.Codec) {
|
||||
r.HandleFunc("/txs/{hash}", QueryTxRequestHandlerFn(cdc, cliCtx)).Methods("GET")
|
||||
r.HandleFunc("/txs/search", SearchTxRequestHandlerFn(cliCtx, cdc)).Methods("GET")
|
||||
r.HandleFunc("/txs", SearchTxRequestHandlerFn(cliCtx, cdc)).Methods("GET")
|
||||
// r.HandleFunc("/txs/sign", SignTxRequstHandler).Methods("POST")
|
||||
r.HandleFunc("/txs", BroadcastTxRequest(cliCtx, cdc)).Methods("POST")
|
||||
}
|
||||
|
|
|
@ -174,7 +174,7 @@ func SearchTxRequestHandlerFn(cliCtx context.CLIContext, cdc *codec.Codec) http.
|
|||
return
|
||||
}
|
||||
|
||||
output, err := cdc.MarshalJSON(txs)
|
||||
output, err := cdc.MarshalJSONIndent(txs, "", " ")
|
||||
if err != nil {
|
||||
w.WriteHeader(500)
|
||||
w.Write([]byte(err.Error()))
|
||||
|
|
Loading…
Reference in New Issue