Updated API for selected dog type

Signed-off-by: Pin <wf6DJd8a3xSSCZbn@protonmail.com>
This commit is contained in:
Pin
2021-01-31 21:20:39 -05:00
parent 0a84e1842e
commit 63ece99593
2 changed files with 49 additions and 2 deletions

View File

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