Skip to content

Instantly share code, notes, and snippets.

@Ananto30
Created March 26, 2020 16:50
Show Gist options
  • Save Ananto30/09b6c4f1c60e0b4eb41a05a82f69dab6 to your computer and use it in GitHub Desktop.
Save Ananto30/09b6c4f1c60e0b4eb41a05a82f69dab6 to your computer and use it in GitHub Desktop.
package main
import (
"fmt"
"io/ioutil"
"log"
"net/http"
)
func HelloServer(w http.ResponseWriter, r *http.Request) {
resp, err := http.Get("http://localhost:8080")
if err != nil {
log.Fatalln(err)
}
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
log.Fatalln(err)
}
log.Println(string(body))
fmt.Fprintf(w, string(body))
}
func main() {
http.HandleFunc("/", HelloServer)
http.ListenAndServe(":8081", nil)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment