adding position and trade endpoints
This commit is contained in:
@@ -42,3 +42,19 @@ 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)
|
||||
if err != nil {
|
||||
http.Error(w, "failed to fetch trades", 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)
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user