| 591 | } |
| 592 | |
| 593 | func runLocalAPIProxy() { |
| 594 | rp := httputil.NewSingleHostReverseProxy(&url.URL{ |
| 595 | Scheme: "http", |
| 596 | Host: apitype.LocalAPIHost, |
| 597 | Path: "/", |
| 598 | }) |
| 599 | dir := rp.Director |
| 600 | rp.Director = func(req *http.Request) { |
| 601 | dir(req) |
| 602 | req.Host = "" |
| 603 | req.RequestURI = "" |
| 604 | } |
| 605 | rp.Transport = localClientRoundTripper{} |
| 606 | lc, err := net.Listen("tcp", "localhost:0") |
| 607 | if err != nil { |
| 608 | log.Fatal(err) |
| 609 | } |
| 610 | fmt.Printf("Serving LocalAPI proxy on http://%s\n", lc.Addr()) |
| 611 | fmt.Printf("curl.exe http://%v/localapi/v0/status\n", lc.Addr()) |
| 612 | fmt.Printf("Ctrl+C to stop") |
| 613 | http.Serve(lc, rp) |
| 614 | } |
| 615 | |
| 616 | var prefsArgs struct { |
| 617 | pretty bool |