Files
gocryptotrader/walletRoutes.go
Scott f37bf8d89f Adds exchange name to account info retrieval
Adds walletRoutes.go
Adds method to get all exchange account stuff  in go
Adds method to get all exchange account stuff in server.js
2016-09-12 20:06:01 +10:00

40 lines
957 B
Go

package main
import (
"encoding/json"
"log"
"net/http"
)
type AllEnabledExchangeAccounts struct {
Data []ExchangeAccountInfo `json:"data"`
}
func GetAllEnabledAccountInfo(w http.ResponseWriter, r *http.Request) {
var response AllEnabledExchangeAccounts
for _, individualBot := range bot.exchanges {
if individualBot != nil && individualBot.IsEnabled() {
individualExchange, err := individualBot.GetExchangeAccountInfo()
if err != nil {
log.Println("Error encountered retrieving exchange account for '" + individualExchange.ExchangeName + "'")
}
response.Data = append(response.Data, individualExchange)
}
}
w.Header().Set("Content-Type", "application/json; charset=UTF-8")
w.WriteHeader(http.StatusOK)
if err := json.NewEncoder(w).Encode(response); err != nil {
panic(err)
}
}
var WalletRoutes = Routes{
Route{
"AllEnabledAccountInfo",
"GET",
"/exchanges/enabled/accounts/all",
GetAllEnabledAccountInfo,
},
}