add trade and position service
This commit is contained in:
@@ -81,15 +81,15 @@ func GetTradeListHandler(db *sql.DB) http.HandlerFunc {
|
||||
|
||||
func GetPositionListHandler(db *sql.DB) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
tradeList, err := database.GetPositions(db)
|
||||
posList, err := database.GetPositions(db)
|
||||
if err != nil {
|
||||
http.Error(w, "failed to fetch trades", http.StatusInternalServerError)
|
||||
http.Error(w, fmt.Sprintf("failed to fetch postiton: %s", err), http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
if err := json.NewEncoder(w).Encode(tradeList); err != nil {
|
||||
http.Error(w, "failed to encode trades", http.StatusInternalServerError)
|
||||
if err := json.NewEncoder(w).Encode(map[string]any{"List": posList}); err != nil {
|
||||
http.Error(w, fmt.Sprintf("failed to encode positions: %s", err), http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user