diff --git a/cmd/serverFunc.go b/cmd/serverFunc.go index 46f09a7..92dd8f6 100644 --- a/cmd/serverFunc.go +++ b/cmd/serverFunc.go @@ -48,18 +48,18 @@ func returnProvince(c *gin.Context) { // TODO: Return prettified HTML representation of the weather based on url parameter } -func pullWeatherInfo(codPostal string) (root, error) { +func pullWeatherInfo(codPostal string) (root, string, error) { jsonData, err := getJSON(localidades[codPostal]) if err != nil { - return root{}, err + return root{}, jsonData, err } textBytes := []byte(jsonData) aemetRequest := root{} err = json.Unmarshal(textBytes, &aemetRequest) if err != nil { - return root{}, err + return root{}, jsonData, err } - return aemetRequest, nil + return aemetRequest, jsonData, nil } func localityIsAvailable(codPostal string) bool { @@ -87,10 +87,11 @@ func returnAPIWeather(c *gin.Context) { return } - aemetRequest, err := pullWeatherInfo(codPostal) + aemetRequest, _, err := pullWeatherInfo(codPostal) if err != nil { e := fmt.Sprint(err) c.String(http.StatusInternalServerError, e) + //c.String(500, jsonData) return } @@ -108,5 +109,4 @@ func returnAPIWeather(c *gin.Context) { c.IndentedJSON(http.StatusOK, aemetRequest) } //c.JSON(http.StatusOK, aemetRequest) - //c.String(http.StatusOK, jsonData) }