mhttp

package
v0.1.23 Latest Latest
Warning

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

Go to latest
Published: May 8, 2021 License: AGPL-3.0 Imports: 24 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type HttpContext

type HttpContext struct {
	Writer  http.ResponseWriter
	Request *http.Request
	// contains filtered or unexported fields
}

func (*HttpContext) ConnectionType

func (h *HttpContext) ConnectionType() string

func (*HttpContext) Send

func (h *HttpContext) Send(msg transports.Message) error

type HttpHandler

type HttpHandler struct {
	Proxy *Proxy // proxy where the ws will be associated
	// contains filtered or unexported fields
}

func (*HttpHandler) AddNamespace

func (h *HttpHandler) AddNamespace(namespace string) error

AddNamespace adds a new namespace to the transport

func (*HttpHandler) AddPeer

func (h *HttpHandler) AddPeer(peer string) error

func (*HttpHandler) AddProxyHandler

func (h *HttpHandler) AddProxyHandler(path string)

AddProxyHandler adds the current websocket handler into the Proxy

func (*HttpHandler) Address

func (h *HttpHandler) Address() string

func (*HttpHandler) ConnectionType

func (h *HttpHandler) ConnectionType() string

func (*HttpHandler) Init

func (h *HttpHandler) Init(c *transports.Connection) error

func (*HttpHandler) Listen

func (h *HttpHandler) Listen(receiver chan<- transports.Message)

func (*HttpHandler) Send

func (h *HttpHandler) Send(msg transports.Message) error

func (*HttpHandler) SendUnicast

func (h *HttpHandler) SendUnicast(address string, msg transports.Message) error

func (*HttpHandler) SetBootnodes

func (h *HttpHandler) SetBootnodes(bootnodes []string)

func (*HttpHandler) SetProxy

func (h *HttpHandler) SetProxy(p *Proxy)

func (*HttpHandler) String

func (h *HttpHandler) String() string

type HttpWsHandler

type HttpWsHandler struct {
	Proxy       *Proxy                 // proxy where the ws will be associated
	Connection  *transports.Connection // the ws connection
	WsReadLimit int64
	// contains filtered or unexported fields
}

HttpWsHandler is a Mixed handler websockets/http

func NewHttpWsHandleWithWsReadLimit added in v0.1.9

func NewHttpWsHandleWithWsReadLimit(readLimit int64) *HttpWsHandler

func (*HttpWsHandler) AddNamespace

func (h *HttpWsHandler) AddNamespace(namespace string) error

AddNamespace adds a new namespace to the transport

func (*HttpWsHandler) AddPeer

func (h *HttpWsHandler) AddPeer(peer string) error

func (*HttpWsHandler) AddProxyHandler

func (h *HttpWsHandler) AddProxyHandler(path string)

AddProxyHandler adds the current websocket handler into the Proxy

func (*HttpWsHandler) Address

func (h *HttpWsHandler) Address() string

func (*HttpWsHandler) ConnectionType

func (h *HttpWsHandler) ConnectionType() string

func (*HttpWsHandler) Init

func (*HttpWsHandler) Listen

func (h *HttpWsHandler) Listen(receiver chan<- transports.Message)

func (*HttpWsHandler) Send

func (h *HttpWsHandler) Send(msg transports.Message) error

func (*HttpWsHandler) SendUnicast

func (h *HttpWsHandler) SendUnicast(address string, msg transports.Message) error

func (*HttpWsHandler) SetBootnodes

func (h *HttpWsHandler) SetBootnodes(bootnodes []string)

func (*HttpWsHandler) SetProxy

func (h *HttpWsHandler) SetProxy(p *Proxy)

func (*HttpWsHandler) String

func (h *HttpWsHandler) String() string

type Proxy

type Proxy struct {
	Conn      *transports.Connection
	Server    *chi.Mux
	Addr      net.Addr
	TLSConfig *tls.Config
}

Proxy represents a proxy

func NewProxy

func NewProxy() *Proxy

NewProxy creates a new proxy instance

func (*Proxy) AddEndpoint

func (p *Proxy) AddEndpoint(url string) func(writer http.ResponseWriter, reader *http.Request)

AddEndpoint adds an endpoint representing the url where the request will be handled

func (*Proxy) AddHandler

func (p *Proxy) AddHandler(path string, handler http.HandlerFunc)

AddHandler adds a HTTP handler in the proxy

func (*Proxy) AddMixedHandler

func (p *Proxy) AddMixedHandler(path string, HTTPhandler http.HandlerFunc, WShandler ProxyWsHandler, WSreadLimit int64)

AddMixedHandler adds a mixed (websockets and HTTP) handler in the proxy

func (*Proxy) AddWsHTTPBridge

func (p *Proxy) AddWsHTTPBridge(url string) ProxyWsHandler

AddWsHTTPBridge adds a WS endpoint to interact with the underlying web3

func (*Proxy) AddWsHandler

func (p *Proxy) AddWsHandler(path string, handler ProxyWsHandler, readLimit int64)

AddWsHandler adds a websocket handler in the proxy

func (*Proxy) AddWsWsBridge

func (p *Proxy) AddWsWsBridge(url string, readLimit int64) ProxyWsHandler

AddWsWsBridge adds a WS endpoint to interact with the underlying websocket server

func (*Proxy) GenerateSSLCertificate

func (p *Proxy) GenerateSSLCertificate(tlsConfig *tls.Config) (*http.Server, *autocert.Manager)

GenerateSSLCertificate generates a SSL certificated for the proxy

func (*Proxy) Init

func (p *Proxy) Init() error

Init checks if SSL is activated or not and runs a http server consequently

When it returns, the server is ready. The returned address is useful if the port was left as 0, to retrieve the randomly allocated port.

func (*Proxy) ProxyIPC

func (p *Proxy) ProxyIPC(path string) http.HandlerFunc

type ProxyWsHandler

type ProxyWsHandler func(c *websocket.Conn)

ProxyWsHandler function signature required to add a handler in the net/http Server

type WebsocketContext

type WebsocketContext struct {
	Conn *websocket.Conn
}

func (WebsocketContext) ConnectionType

func (c WebsocketContext) ConnectionType() string

func (*WebsocketContext) Send

type WebsocketHandle

type WebsocketHandle struct {
	Connection *transports.Connection // the ws connection
	WsProxy    *Proxy                 // proxy where the ws will be associated
	ReadLimit  int64
	// contains filtered or unexported fields
}

WebsocketHandle handles the websockets connection on the go-dvote proxy

func NewWebSocketHandleWithReadLimit added in v0.1.8

func NewWebSocketHandleWithReadLimit(readLimit int64) *WebsocketHandle

func (*WebsocketHandle) AddNamespace

func (w *WebsocketHandle) AddNamespace(namespace string) error

Listen will listen the websockets handler and write the received data into the channel

func (*WebsocketHandle) AddPeer

func (w *WebsocketHandle) AddPeer(peer string) error

func (*WebsocketHandle) AddProxyHandler

func (w *WebsocketHandle) AddProxyHandler(path string)

AddProxyHandler adds the current websocket handler into the Proxy

func (*WebsocketHandle) Address

func (w *WebsocketHandle) Address() string

func (*WebsocketHandle) ConnectionType

func (w *WebsocketHandle) ConnectionType() string

ConnectionType returns a string identifying the transport connection type

func (*WebsocketHandle) Init

Init initializes the websockets handler and the internal channel to communicate with other go-dvote components

func (*WebsocketHandle) Listen

func (w *WebsocketHandle) Listen(receiver chan<- transports.Message)

Listen will listen the websockets handler and write the received data into the channel

func (*WebsocketHandle) Send

func (w *WebsocketHandle) Send(msg transports.Message) error

Send sends the response given a message

func (*WebsocketHandle) SendUnicast

func (w *WebsocketHandle) SendUnicast(address string, msg transports.Message) error

func (*WebsocketHandle) SetBootnodes

func (w *WebsocketHandle) SetBootnodes(bootnodes []string)

func (*WebsocketHandle) SetProxy

func (w *WebsocketHandle) SetProxy(p *Proxy)

SetProxy sets the proxy for the ws

func (*WebsocketHandle) String

func (w *WebsocketHandle) String() string

Jump to

Keyboard shortcuts

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