Files
pokeval/api/lookup_handler.go
2025-04-28 00:04:14 +02:00

38 lines
901 B
Go

package api
import (
"encoding/json"
"net/http"
"pokeval/db"
)
// GET /api/v1/platforms
func GetPlatforms(w http.ResponseWriter, r *http.Request) {
rows, _ := db.DB.Query("SELECT id, platform_name FROM auction_platform")
defer rows.Close()
var platforms []map[string]interface{}
for rows.Next() {
var id int
var name string
rows.Scan(&id, &name)
platforms = append(platforms, map[string]interface{}{"id": id, "name": name})
}
json.NewEncoder(w).Encode(platforms)
}
// GET /api/v1/currencies
func GetCurrencies(w http.ResponseWriter, r *http.Request) {
rows, _ := db.DB.Query("SELECT id, currency_code FROM currency")
defer rows.Close()
var currencies []map[string]interface{}
for rows.Next() {
var id int
var code string
rows.Scan(&id, &code)
currencies = append(currencies, map[string]interface{}{"id": id, "code": code})
}
json.NewEncoder(w).Encode(currencies)
}