Documentation ¶
Overview ¶
Example (Integrated) ¶
package main import ( "fmt" "log" "net/http" "net/http/httputil" "time" "bazil.org/bazil/util/httpunix" ) func main() { u := &httpunix.HTTPUnixTransport{ DialTimeout: 100 * time.Millisecond, RequestTimeout: 1 * time.Second, ResponseHeaderTimeout: 1 * time.Second, } u.RegisterLocation("foo", "sock") // If you want to use http: with the same client: t := &http.Transport{} t.RegisterProtocol(httpunix.Scheme, u) var client = http.Client{ Transport: t, } resp, err := client.Get("http+unix://foo/bar") if err != nil { log.Fatal(err) } buf, err := httputil.DumpResponse(resp, true) if err != nil { log.Fatal(err) } fmt.Printf("%s", buf) resp.Body.Close() }
Output:
Example (Standalone) ¶
package main import ( "fmt" "log" "net/http" "net/http/httputil" "time" "bazil.org/bazil/util/httpunix" ) func main() { u := &httpunix.HTTPUnixTransport{ DialTimeout: 100 * time.Millisecond, RequestTimeout: 1 * time.Second, ResponseHeaderTimeout: 1 * time.Second, } u.RegisterLocation("foo", "sock") var client = http.Client{ Transport: u, } resp, err := client.Get("http+unix://foo/bar") if err != nil { log.Fatal(err) } buf, err := httputil.DumpResponse(resp, true) if err != nil { log.Fatal(err) } fmt.Printf("%s", buf) resp.Body.Close() }
Output:
Index ¶
Examples ¶
Constants ¶
View Source
const Scheme = "http+unix"
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type HTTPUnixTransport ¶
type HTTPUnixTransport struct { DialTimeout time.Duration RequestTimeout time.Duration ResponseHeaderTimeout time.Duration // contains filtered or unexported fields }
func (*HTTPUnixTransport) RegisterLocation ¶
func (u *HTTPUnixTransport) RegisterLocation(loc string, path string)
Click to show internal directories.
Click to hide internal directories.