Fetch the repository succeeded.
package main
import (
"btc/web"
"flag"
"github.com/labstack/echo/v4"
"github.com/labstack/echo/v4/middleware"
"runtime"
)
var (
version = "main"
gitCommitHash = ""
)
func main() {
var addr string
flag.StringVar(&addr, "addr", "localhost:8000", "")
flag.Parse()
app := echo.New()
app.Use(middleware.Recover())
app.Use(middleware.CORS())
app.Use(middleware.RequestID())
app.Use(middleware.Logger())
app.HideBanner = true
app.RouteNotFound("/*", web.DefaultNotFound)
// info
app.Any("/", func(c echo.Context) error {
return c.JSON(200, struct {
Code int `json:"code"`
Version string `json:"version"`
GoVersion string `json:"go-version"`
GitHash string `json:"git-commit-hash"`
}{
Code: 200,
Version: version,
GoVersion: runtime.Version(),
GitHash: gitCommitHash,
})
})
// addresses
app.Match([]string{"GET", "POST"}, "/address/new", web.NewAddress)
app.Match([]string{"GET", "POST"}, "/address/parse", web.ParseAddress)
app.Match([]string{"GET", "POST"}, "/address/new-multi-sig", web.NewMultiSigAddress)
// transactions
app.Match([]string{"GET", "POST"}, "/transaction/decode", web.DecodeTransaction)
app.POST("/transaction/create", web.CreateRawTransaction)
app.POST("/transaction/sign", web.SignTransaction)
app.POST("/transaction/create-and-sign", web.CreateAndSignTransaction)
app.Logger.Fatal(app.Start(addr))
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。