Created
June 23, 2015 15:01
-
-
Save rphillips/6a1094319114346bdfc0 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( | |
"io/ioutil" | |
"fmt" | |
"net" | |
"net/http" | |
"log" | |
) | |
func fakeDial(proto, addr string) (conn net.Conn, err error) { | |
fmt.Println("using domain socket") | |
return net.Dial("unix", "/var/xapi/xapi") | |
} | |
func main() { | |
tr := &http.Transport{ | |
Dial: fakeDial, | |
} | |
client := &http.Client{Transport: tr} | |
req, err := http.NewRequest("GET", "http://127.0.0.1/rrd_updates?start=1435024500&host=true&cf=AVERAGE", nil) | |
req.SetBasicAuth("root", "testing") | |
resp, err := client.Do(req) | |
if err != nil { | |
log.Fatal(err) | |
} | |
defer resp.Body.Close() | |
body, err := ioutil.ReadAll(resp.Body) | |
if err != nil { | |
log.Fatal(err) | |
} | |
fmt.Print(string(body)) | |
} | |
// GOOS=linux GOARCH=386 go build |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment