Registry / networking / libp2p-go-libp2p-http

libp2p-go-libp2p-http

JSON →
library0.5.0gogounverified

Package p2phttp enables serving HTTP endpoints and making HTTP requests through libp2p using Go's standard http and net stacks, leveraging libp2p features like multi-routes and NAT traversal.

go get github.com/libp2p/go-libp2p-http
INSTALL
IMPORT
SIG · LIBP2P-GO-LIBP2P-H
L
libp2p-go-libp2p-http
networkinggov0.5.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

p2phttp
github.com/libp2p/go-libp2p-http

Starts an HTTP server over libp2p using p2phttp listener.

package main import ( "net/http" "github.com/libp2p/go-libp2p" p2phttp "github.com/libp2p/go-libp2p-http" ) func main() { host, _ := libp2p.New() server := &http.Server{Handler: http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { w.Write([]byte("Hello from libp2p!")) })} ln, _ := p2phttp.Listen(host, "/p2p/http") server.Serve(ln) }
Debug
Known issues
gotchalibp2p hosts cannot dial themselves; server and client must be different hosts.
fix
Use separate libp2p hosts for server and client when testing locally.
affects: all
Upgrade
Version history
0.5.0latest on pkg.go.dev
Audit
Dependencies

No dependency data recorded yet.

Agent activity
4 hits · last 30 days
node
4
Resources
libp2p-go-libp2p-http — go get libp2p-go-libp2p-http · libregistry