Registry / networking / hsanjuan-go-libp2p-http

hsanjuan-go-libp2p-http

JSON →
library0.5.0gogounverified

Allows serving and making HTTP requests over libp2p using Go's standard http and net stacks.

go get github.com/hsanjuan/go-libp2p-http
INSTALL
IMPORT
SIG · HSANJUAN-GO-LIBP2P
H
hsanjuan-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/hsanjuan/go-libp2p-http

Starts an HTTP server over libp2p.

package main import ( "fmt" "net/http" "github.com/hsanjuan/go-libp2p-http" ) func main() { host, _ := libp2p.New() ln, _ := p2phttp.Listen(host, "/my-protocol") http.Serve(ln, http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { fmt.Fprintln(w, "Hello from libp2p!") })) }
Debug
Known issues
gotchalibp2p hosts cannot dial themselves, so the same host cannot act as both server and client.
fix
Use separate hosts for client and server roles.
affects: >=0.1.0
Upgrade
Version history
0.5.0latest on pkg.go.dev
Audit
Dependencies

No dependency data recorded yet.

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