Answers for "handle get request and send response golang"

Go
0

golang get request data

package main

func fetchResponse(url string) string{
	resp, _ := http.Get(url)	
	defer resp.Body.Close()
	body, _ := ioutil.ReadAll(resp.Body)
	return string(body)
}

func main() {	
	resp := fetchResponse("http://someurl.com")
	fmt.Println(resp)
}
Posted by: Guest on October-20-2020
0

golang http writer redirect

func redirect(w http.ResponseWriter, r *http.Request) {
    http.Redirect(w, r, "http://www.google.com", 301)
}
Posted by: Guest on January-04-2021

Code answers related to "handle get request and send response golang"

Browse Popular Code Answers by Language