Commit e323c379 authored by Aksel Baardsen's avatar Aksel Baardsen
Browse files

no real changes

parent c412101f
......@@ -5,14 +5,13 @@ import (
"github.com/gorilla/mux"
"log"
"net/http"
"os"
)
func main() {
r := mux.NewRouter()
port := os.Getenv("PORT")
port := "5000"//port := os.Getenv("PORT")
c := r.PathPrefix("/conservation/v1").Methods("GET").Subrouter()
// two handlerpaths makes sure that the caller does not HAVE to specify limit
......@@ -26,7 +25,7 @@ func main() {
c.Path("/species/{speciesKey}").
HandlerFunc(handler.Shandler)
c.Path("/diag/").
c.Path("/diag").
HandlerFunc(handler.Dhandler)
http.Handle("/", r)
......
......@@ -29,8 +29,11 @@ type Results struct {
func GetCountryByCode(code, limit string) Country {
var country Country
// gets country info
var species Response
urlCountry := countryApi + code
urlSpecies := occurrenceApi + "country=" + code + "&limit=" + limit
// gets country info
cBody := getString(urlCountry)
err := json.Unmarshal([]byte(cBody), &country)
if err != nil {
......@@ -38,8 +41,6 @@ func GetCountryByCode(code, limit string) Country {
}
// gets species in that country
var species Response
urlSpecies := occurrenceApi + "country=" + code + "&limit=" + limit
rBody := getString(urlSpecies)
err = json.Unmarshal([]byte(rBody), &species)
if err != nil {
......
......@@ -18,11 +18,10 @@ func getString(url string) string {
bodyBytes, err := ioutil.ReadAll(resp.Body)
if err != nil {
log.Fatal(err)
return "err0r"
}
bodyString = string(bodyBytes)
} else {
return "err0r"
log.Fatal(resp.StatusCode)
}
return bodyString
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment