Allow pulling raw json for debugging

This commit is contained in:
raul 2024-05-27 09:03:42 +02:00
parent 0863a258c6
commit 6468294478
1 changed files with 6 additions and 6 deletions

View File

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