Created
March 26, 2020 16:50
-
-
Save Ananto30/09b6c4f1c60e0b4eb41a05a82f69dab6 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
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