Updated API for selected dog type
Signed-off-by: Pin <wf6DJd8a3xSSCZbn@protonmail.com>
This commit is contained in:
@@ -29,7 +29,15 @@ func APIHandler(w http.ResponseWriter, r *http.Request) {
|
||||
switch r.Method {
|
||||
case "GET":
|
||||
var dogquery structs.DogPicRow
|
||||
dogquery = db.RandomSelect()
|
||||
json.NewEncoder(w).Encode(dogquery)
|
||||
keys := r.URL.Query().Get("dog")
|
||||
if len(keys) == 0 {
|
||||
dogquery = db.RandomSelect()
|
||||
json.NewEncoder(w).Encode(dogquery)
|
||||
return
|
||||
} else {
|
||||
dogquery = db.DogSelect(keys)
|
||||
json.NewEncoder(w).Encode(dogquery)
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user