diff --git a/country.go b/country.go index 155a5f1d283bbca69069cea9897060432027925f..19ce497556f21ceeb8943230604a017e0534d5a3 100644 --- a/country.go +++ b/country.go @@ -29,11 +29,8 @@ func speciesInCountryRequest(url string, c *http.Client, country *Country) { // sends a request for species in a country and gets the response resp := doRequest(url, c) - // array of results structs - type Result Results - // empty result struct - var nameAndKey = &Result{} + var nameAndKey = &Results{} // decodes the response into the array of results err := json.NewDecoder(resp.Body).Decode(nameAndKey) @@ -69,13 +66,12 @@ func HandlerCountry(w http.ResponseWriter, r *http.Request) { // gets the query we want and splits the string into parts urlQuery := r.URL.RawQuery parts := strings.Split(r.URL.Path, "/") - /* - if len(parts) != 5 || parts[1] != "conservation" || parts[2] != "v1" || parts[3] != "country" || parts[4] == "" { - status := http.StatusBadRequest - http.Error(w, "Expecting format /conservation/v1/country/'AlphaCode'", status) - return - } - */ + + if len(parts) != 5 || parts[1] != "conservation" || parts[2] != "v1" || parts[3] != "country" || parts[4] == "" { + status := http.StatusBadRequest + http.Error(w, "Expecting format /conservation/v1/country/'AlphaCode'", status) + return + } // appends the country-code to the country api and appends country-code and limit to the species api APIURL += parts[4]