Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var DefaultP2PProtocol protocol.ID = "/libp2p-stdhttp"
DefaultP2PProtocol is used to tag and identify streams handled by go-libp2p-stdhttp
Functions ¶
Types ¶
type Option ¶
type Option func(o *options)
Option allows to set the libp2p transport options.
func ProtocolOption ¶
ProtocolOption sets the Protocol Tag associated to the libp2p roundtripper.
type RoundTripper ¶
type RoundTripper struct {
// contains filtered or unexported fields
}
RoundTripper implemenets stdhttp.RoundTrip and can be used as custom transport with Go stdhttp.Client.
func NewTransport ¶
func NewTransport(h host.Host, opts ...Option) *RoundTripper
NewTransport returns a new RoundTripper which uses the provided libP2P host to perform an stdhttp request and obtain the response.
The typical use case for NewTransport is to register the "libp2p" protocol with a Transport, as in:
t := &stdhttp.Transport{} t.RegisterProtocol("libp2p", p2phttp.NewTransport(host, ProtocolOption(DefaultP2PProtocol))) c := &stdhttp.Client{Transport: t} res, err := c.Get("libp2p://Qmaoi4isbcTbFfohQyn28EiYM5CDWQx9QRCjDh3CTeiY7P/index.html") ...
Click to show internal directories.
Click to hide internal directories.