forked from thrasher-corp/gocryptotrader
-
Notifications
You must be signed in to change notification settings - Fork 1
/
walletRoutes.go
39 lines (34 loc) · 957 Bytes
/
walletRoutes.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
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,
},
}