Skip to content

Instantly share code, notes, and snippets.

@aavrug
Created August 4, 2020 05:24
Show Gist options
  • Save aavrug/ff970ffc016c0b7377d8661a01da9185 to your computer and use it in GitHub Desktop.
Save aavrug/ff970ffc016c0b7377d8661a01da9185 to your computer and use it in GitHub Desktop.
func requestHandler(w http.ResponseWriter, r *http.Request) {
if r.Method == http.MethodGet {
resp := sendRequest(w, r)
fmt.Println(resp)
fmt.Println(reflect.TypeOf(resp))
var dat map[string]interface{}
if err := json.Unmarshal(resp, &dat); err != nil {
panic(err)
}
fmt.Println(dat)
return dat
// fmt.Fprintf(w, "Success")
// response, err := json.Marshal(resp)
// if err != nil {
// fmt.Println(err)
// }
// w.Header().Set("Content-Type", "application/json; charset=utf-8")
// w.WriteHeader(http.StatusOK)
// w.Write(response)
// fmt.Fprintf(w, response)
// fmt.Println("This is a get request")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment