Documentation
¶
Overview ¶
package unixtransport allows HTTP client requests to Unix sockets.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Register ¶
Register adds a protocol handler to the provided transport that can serve requests to Unix domain sockets via the "http+unix" or "https+unix" schemes. Request URLs should have the following form:
https+unix:///path/to/socket:/request/path?query=val&...
The registered transport is based on a clone of the provided transport, and so uses the same configuration: timeouts, TLS settings, and so on. Connection pooling should also work as normal. One caveat: only the DialContext and DialTLSContext dialers are respected; the Dial and DialTLS dialers are explicitly removed and ignored.
Example (Custom) ¶
package main import ( "net/http" "gitlab.com/opennota/unixtransport" ) func main() { t := &http.Transport{ // ... } unixtransport.Register(t) c := &http.Client{ Transport: t, // ... } c.Get("https+unix:///tmp/my.sock") }
Output:
Example (Default) ¶
package main import ( "net/http" "gitlab.com/opennota/unixtransport" ) func main() { // Register the "http+unix" and "https+unix" protocols in the default client transport. unixtransport.Register(http.DefaultTransport.(*http.Transport)) // This will issue a GET request to an HTTP server listening at /tmp/my.sock. // Note the three '/' characters between 'http+unix:' and 'tmp'. http.Get("http+unix:///tmp/my.sock") // This shows how to include a request path and query. http.Get("http+unix:///tmp/my.sock:/users/123?q=abc") }
Output:
Types ¶
This section is empty.
Directories
¶
Path | Synopsis |
---|---|
package unixproxy provides an EXPERIMENTAL reverse proxy to Unix sockets.
|
package unixproxy provides an EXPERIMENTAL reverse proxy to Unix sockets. |
Click to show internal directories.
Click to hide internal directories.