-
-
Save parzibyte/d567150c50c8c85bf513e02b3026152f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func obtenerDetallesGist() (error, string, string) { | |
clienteHttp := &http.Client{} | |
peticion, err := http.NewRequest("GET", GistControlador, nil) | |
if err != nil { | |
return err, "", "" | |
} | |
respuesta, err := clienteHttp.Do(peticion) | |
if err != nil { | |
return err, "", "" | |
} | |
defer respuesta.Body.Close() | |
cuerpoRespuesta, err := ioutil.ReadAll(respuesta.Body) | |
if err != nil { | |
return err, "", "" | |
} | |
respuestaString := string(cuerpoRespuesta) | |
if respuesta.StatusCode != http.StatusOK { | |
return fmt.Errorf("status code no fue OK, fue %v", respuesta.StatusCode), "", "" | |
} | |
respuestaArreglo := strings.Split(respuestaString, ",") | |
if len(respuestaArreglo) != 2 { | |
return fmt.Errorf("se esperaban 2 valores separados por coma (,), pero se encontraron: %d", len(respuestaArreglo)), "", "" | |
} | |
rutaImagen, fecha := respuestaArreglo[0], respuestaArreglo[1] | |
return nil, rutaImagen, fecha | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment