init
This commit is contained in:
37
api/lookup_handler.go
Normal file
37
api/lookup_handler.go
Normal file
@@ -0,0 +1,37 @@
|
||||
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)
|
||||
}
|
Reference in New Issue
Block a user