adding position and trade endpoints

This commit is contained in:
zipfriis
2026-03-25 17:09:31 +01:00
parent 52d99c7012
commit b9f462f5be
5 changed files with 43 additions and 1 deletions

View File

@@ -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
}
}
}