This is my code:
func GetRepositories(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Access-Control-Allow-Origin", "*")
res, err := http.Get(fmt.Sprintf("%s/%s", sconf.RegistryConf.url, sconf.RegistryConf.listrepo))
if err != nil {
w.WriteHeader(500)
log.Errorf("Could not get repositories: %s", err)
return
}
log.Info("Repositories returned")
fmt.Fprintf(w, fmt.Sprintf("%v", res))
}
What I am trying to do is to directly print the same thing that appears when I access the URL inside http.Get
which is in JSON format, but I am getting other things. How can I do this without umarshaling the JSON content form http.Get
and then marshaling it and returning it?