8000 GitHub - agorman/httpunix: Go library to talk HTTP over Unix domain sockets
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

agorman/httpunix

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Godoc

Package httpunix provides a HTTP transport (net/http.RoundTripper) that uses Unix domain sockets instead of HTTP.

forked from https://github.com/tv42/httpunix

Why

I forked this project because I wanted to provide a URL representation for http+unix addresses rather than have to register each unix socket programmatically.

URLs

The URLs look like this:

http+unix://unix:LOCATION:/PATH_ETC

where LOCATION is the file system path to the unix socket file, and PATH_ETC follow normal http: scheme conventions.

Example

// This example shows handling all net/http requests for the
// http+unix URL scheme.
u := &httpunix.Transport{
	DialTimeout:           100 * time.Millisecond,
	RequestTimeout:        1 * time.Second,
	ResponseHeaderTimeout: 1 * time.Second,
}

// 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://unix:/path/to/socket:/urlpath/as/seen/by/server")
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()

About

Go library to talk HTTP over Unix domain sockets

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 100.0%
0