Created
December 22, 2015 22:15
-
-
Save markstgodard/d6b944edfc98a5901eb5 to your computer and use it in GitHub Desktop.
golang absolute request test
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" | |
"net/http" | |
) | |
func main() { | |
client := &http.Client{} | |
req, _ := http.NewRequest("GET", "http://dora.bosh-lite.com/env", nil) | |
req.Header.Add("Host", `dora.bosh-lite.com`) | |
req.URL.Path = "http://dora.bosh-lite.com/env" | |
resp, err := client.Do(req) | |
if err != nil { | |
fmt.Println("Error: ", err.Error()) | |
} | |
defer resp.Body.Close() | |
body, err := ioutil.ReadAll(resp.Body) | |
if err != nil { | |
fmt.Println("Error: ", err.Error()) | |
} | |
fmt.Printf("Body: %s\n", body) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Run using: