本文整理汇总了Golang中github.com/skycoin/skycoin/src/daemon.Gateway.GetWallet方法的典型用法代码示例。如果您正苦于以下问题:Golang Gateway.GetWallet方法的具体用法?Golang Gateway.GetWallet怎么用?Golang Gateway.GetWallet使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/skycoin/skycoin/src/daemon.Gateway
的用法示例。
在下文中一共展示了Gateway.GetWallet方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: walletHandlerPOST
// Create a wallet if no ID provided. Otherwise update an existing wallet.
// Name the wallet with "name".
func walletHandlerPOST(gateway *daemon.Gateway, w http.ResponseWriter,
r *http.Request) {
id := wallet.WalletID(r.FormValue("id"))
name := r.FormValue("name")
if id == "" {
// Create wallet
iw := gateway.CreateWallet()
if iw != nil {
w := iw.(wallet.Wallet)
w.SetName(name)
if err := gateway.SaveWallet(w.GetID()); err != nil {
m := "Failed to save wallet after renaming: %v"
logger.Critical(m, err)
}
}
SendOr500(w, iw)
} else {
// Update wallet
iw := gateway.GetWallet(id)
if iw != nil {
w := iw.(wallet.Wallet)
w.SetName(name)
if err := gateway.SaveWallet(w.GetID()); err != nil {
m := "Failed to save wallet after renaming: %v"
logger.Critical(m, err)
}
}
SendOr404(w, iw)
}
}
示例2: walletHandler
// Returns a wallet by ID if GET. Creates or updates a wallet if POST.
func walletHandler(gateway *daemon.Gateway) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
if r.Method == "GET" {
SendOr404(w, gateway.GetWallet(wallet.WalletID(r.FormValue("id"))))
} else if r.Method == "POST" {
walletHandlerPOST(gateway, w, r)
} else {
Error405(w)
}
}
}
示例3: walletHandler
func walletHandler(gateway *daemon.Gateway) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
SendOr404(w, gateway.GetWallet())
}
}