go_http_js_libp2p

package module
v0.0.0-...-783164a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 18, 2020 License: Apache-2.0 Imports: 7 Imported by: 0

README

go-http-js-libp2p

Tunnel HTTP requests/responses in-browser from go-wasm over js-libp2p. In theory should be compatible with https://github.com/libp2p/go-libp2p-http.

To test:

$ yarn install
$ ./test.sh

Alternatively:

$ docker build -t ghjl .
$ docker run --rm ghjl

The tests will spin up a rendezvous server. For reference, you can spin one up like this:

npm install --global libp2p-websocket-star-rendezvous
rendezvous --port=9090 --host=127.0.0.1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Await

func Await(v js.Value) (result js.Value, ok bool)

Await waits until the promise v has been resolved or rejected and returns the promise's result value. The boolean value ok is true if the promise has been resolved, false if it has been rejected. If v is not a promise, v itself is returned as the value and ok is true.

func NewP2pTransport

func NewP2pTransport(p2pLocalNode *P2pLocalNode) *p2pTransport

NewP2pTransport returns an http.RoundTripper

Types

type P2pLocalNode

type P2pLocalNode struct {
	Service string
	Id      string
	// contains filtered or unexported fields
}

func NewP2pLocalNode

func NewP2pLocalNode(service string, seed []byte, addrs []string, namespace string) *P2pLocalNode

NewP2pLocalNode creates a new P2pLocalNode and starts it.

func (*P2pLocalNode) Js

func (pn *P2pLocalNode) Js() js.Value

func (*P2pLocalNode) RegisterFoundProviders

func (pn *P2pLocalNode) RegisterFoundProviders(handler func([]PeerInfo))

func (*P2pLocalNode) RegisterPeerConnect

func (pn *P2pLocalNode) RegisterPeerConnect(handler func(*PeerInfo))

func (*P2pLocalNode) RegisterPeerDisconnect

func (pn *P2pLocalNode) RegisterPeerDisconnect(handler func(*PeerInfo))

func (*P2pLocalNode) RegisterPeerDiscover

func (pn *P2pLocalNode) RegisterPeerDiscover(handler func(*PeerInfo))

type PeerInfo

type PeerInfo struct {
	Id string
	// contains filtered or unexported fields
}

func NewPeerInfo

func NewPeerInfo(jsPeerInfo js.Value) *PeerInfo

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL