Skip to content

Instantly share code, notes, and snippets.

@markstgodard
Created December 22, 2015 22:15
Show Gist options
  • Save markstgodard/d6b944edfc98a5901eb5 to your computer and use it in GitHub Desktop.
Save markstgodard/d6b944edfc98a5901eb5 to your computer and use it in GitHub Desktop.
golang absolute request test
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)
}
@markstgodard
Copy link
Author

Run using:

go run main.go

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment