httpweave

package
v0.0.0-...-c640e2a Latest Latest
Warning

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

Go to latest
Published: May 17, 2017 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package httpweave provides a http layer for communicate with a low-level tcp server through http requests.

Index

Constants

This section is empty.

Variables

View Source
var ErrClosedConnection = errors.New("Connection Closed")

ErrClosedConnection is returned when the giving client connection has being closed.

Functions

This section is empty.

Types

type TCPClient

type TCPClient struct {
	net.Conn
	// contains filtered or unexported fields
}

TCPClient defines a interface for a type which connects to a tcp endpoint and provides read and write capabilities.

func NewTCPClient

func NewTCPClient(addr string, config *tls.Config) (*TCPClient, error)

NewTCPClient returns a new instance of a TCPClient.

func (*TCPClient) Close

func (t *TCPClient) Close() error

Close ends and disposes of the internal connection, closing it and all reads and writers.

func (*TCPClient) Read

func (t *TCPClient) Read() ([]byte, error)

Read reads the current available data from the pipeline.

func (*TCPClient) Write

func (t *TCPClient) Write(data []byte, flush bool) error

Write writes the current available data from the pipeline.

type WeaveAttr

type WeaveAttr struct {
	Addr          string
	TargetAddr    string
	Headers       http.Header
	Transformer   octo.TCPTransformer
	Auth          octo.Authenticator
	TLSConfig     *tls.Config
	TCPTLSConfig  *tls.Config
	Notifications chan []byte
}

WeaveAttr defines a attribute struct for defining options for the WebWeaveServer struct.

type WeaveServer

type WeaveServer struct {
	Attr WeaveAttr
	// contains filtered or unexported fields
}

WeaveServer defines a struct implements the http.ServeHTTP interface which handles servicing http requests for websockets.

func New

func New(instrument octo.Instrumentation, attr WeaveAttr) *WeaveServer

New returns a new instance of a WeaveServer.

func (*WeaveServer) Close

func (s *WeaveServer) Close() error

Close ends the websocket connection and ensures all requests are finished.

func (*WeaveServer) Listen

func (s *WeaveServer) Listen() error

Listen begins the initialization of the websocket server.

func (*WeaveServer) ServeHTTP

func (s *WeaveServer) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP implements the http.Handler.ServeHTTP interface method to handle http request converted to websockets request.

func (*WeaveServer) Wait

func (s *WeaveServer) Wait()

Wait awaits the closure of the giving client.

type WeaveServerMux

type WeaveServerMux struct {
	Attr               WeaveAttr
	OverrideTargetAddr string // targetAddr to be used regardless of incoming data from client.
	// contains filtered or unexported fields
}

WeaveServerMux defines a struct which implements the http.Handler interface for handling http server-sent requests.

func NewWeaveServerMux

func NewWeaveServerMux(instruments octo.Instrumentation, auth octo.Authenticator, transfomer octo.TCPTransformer, info octo.Contact, targetAddr string, config *tls.Config) *WeaveServerMux

NewWeaveServerMux returns a new instance of a WeaveServerMux which will use the provided targetAddr if provided as destination else use that from the incoming data from the request.

func (*WeaveServerMux) ServeHTTP

func (s *WeaveServerMux) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP implements the http.Handler.ServeHTTP interface method to handle http request converted to websockets request.

Jump to

Keyboard shortcuts

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