client/rest, modules/coin/rest: moved code around
After offline emails and a video call with @ethanfrey, a goal was decided to move things around i.e: - [X] Move /build/send and /query/account to modules/coin/rest Due to that move, there is a lot of overlap between needed code and utils so extracted common code to make https://github.com/tendermint/tmlibs/pull/33 so make sure to pull in that commit into your tmlibs tree. After code review feedback: client/rest, modules/coin/rest: FoutputProof, PrepareSendTx helper * Extract OutputProof to FoutputProof helper that can be used in modules/coin/rest/handlers.go as proofs.FoutputProof * Revert r.HandleFunc("/tx", doPostTx).Methods("POST") which was erraneously deleted * Use function signatures from "tendermint/tmblibs/common"
This commit is contained in:
+1
-33
@@ -1,12 +1,9 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"net/http"
|
||||
"os"
|
||||
|
||||
"github.com/gorilla/mux"
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"github.com/tendermint/basecoin/client/commands"
|
||||
@@ -20,24 +17,12 @@ var srvCli = &cobra.Command{
|
||||
Long: `Baseserver presents a nice (not raw hex) interface to the basecoin blockchain structure.`,
|
||||
}
|
||||
|
||||
var serveCmd = &cobra.Command{
|
||||
Use: "serve",
|
||||
Short: "Serve the light REST client for tendermint",
|
||||
Long: "Access basecoin via REST",
|
||||
RunE: serve,
|
||||
}
|
||||
|
||||
var port int
|
||||
|
||||
func main() {
|
||||
commands.AddBasicFlags(srvCli)
|
||||
|
||||
flagset := serveCmd.Flags()
|
||||
flagset.IntVar(&port, "port", 8998, "the port to run the server on")
|
||||
|
||||
srvCli.AddCommand(
|
||||
commands.InitCmd,
|
||||
serveCmd,
|
||||
rest.ServeCmd,
|
||||
)
|
||||
|
||||
// TODO: Decide whether to use $HOME/.basecli for compatibility
|
||||
@@ -47,20 +32,3 @@ func main() {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
const defaultAlgo = "ed25519"
|
||||
|
||||
func serve(cmd *cobra.Command, args []string) error {
|
||||
keysManager := rest.DefaultKeysManager()
|
||||
router := mux.NewRouter()
|
||||
ctx := rest.Context{
|
||||
Keys: rest.New(keysManager, defaultAlgo),
|
||||
}
|
||||
if err := ctx.RegisterHandlers(router); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
addr := fmt.Sprintf(":%d", port)
|
||||
log.Printf("Serving on %q", addr)
|
||||
return http.ListenAndServe(addr, router)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user