http

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: 20 Imported by: 0

Documentation

Overview

Package http provides a server which implements server push system provided by the new go http package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BasicAttr

type BasicAttr struct {
	Addr         string
	Authenticate bool
	SkipCORS     bool
	Headers      http.Header
	TLSConfig    *tls.Config
	Auth         octo.AuthCredential
}

BasicAttr defines a attribute struct for defining options for the WebBasicServer struct.

type BasicServeAttr

type BasicServeAttr struct {
	Authenticate bool
	SkipCORS     bool
	Instruments  octo.Instrumentation
	Info         octo.Contact
	Auth         octo.Credentials
	System       stream.System
	Pub          *stream.Pub
}

BasicServeAttr defines a attribute which holds configuration fields for a BasicServeHTTP.

type BasicServeHTTP

type BasicServeHTTP struct {
	Attr BasicServeAttr
	// contains filtered or unexported fields
}

BasicServeHTTP provides a structure which implements the http.Handler and provides the core server which implements the needed functionality to use the streams.System interface. It is provided as a seperate module to allow flexibility with user created server and routes for http requests.

func NewBasicServeHTTP

func NewBasicServeHTTP(attr BasicServeAttr) *BasicServeHTTP

NewBasicServeHTTP returns a new instance of the BasicServeHTTP object.

func (*BasicServeHTTP) Contact

func (s *BasicServeHTTP) Contact() octo.Contact

Contact returns the info object associated with this server.

func (*BasicServeHTTP) ServeHTTP

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

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

type BasicServer

type BasicServer struct {
	Attr BasicAttr
	// contains filtered or unexported fields
}

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

func New

func New(instruments octo.Instrumentation, attr BasicAttr) *BasicServer

New returns a new instance of a BasicServer.

func (*BasicServer) Close

func (s *BasicServer) Close() error

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

func (*BasicServer) Credential

func (s *BasicServer) Credential() octo.AuthCredential

Credential return the giving credentails of the provided server.

func (*BasicServer) Listen

func (s *BasicServer) Listen(system stream.System) error

Listen begins the initialization of the websocket server.

func (*BasicServer) Register

func (s *BasicServer) Register(tm stream.StateHandlerType, hmi interface{})

Register registers the handler for a given handler.

func (*BasicServer) ServeHTTP

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

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

func (*BasicServer) Wait

func (s *BasicServer) Wait()

Wait awaits the closure of the giving client.

type BasicTransmission

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

BasicTransmission defines a struct to hold the request and response object. All HTTP Request are expected to use the 'Authorization' header which will contain the `SCHEME TOKEN:APIKEY:APIDATA'` which will then be used for authentication if the

func (*BasicTransmission) Close

func (t *BasicTransmission) Close() error

Close ends the internal conneciton.

func (*BasicTransmission) Contact

func (t *BasicTransmission) Contact() (octo.Contact, octo.Contact)

Contact returns the giving information for the internal client and server.

func (*BasicTransmission) Ctx

Ctx returns the context that is related to this object.

func (*BasicTransmission) Send

func (t *BasicTransmission) Send(data []byte, flush bool) error

Send pipes the giving data down the provided pipeline.

func (*BasicTransmission) SendAll

func (t *BasicTransmission) SendAll(data []byte, flush bool) error

SendAll pipes the giving data down the provided pipeline. This function call the BasicTransmission.Send function internally, as multiple requests is not supported.

type SSEClient

type SSEClient struct {
	Data bytes.Buffer
	// contains filtered or unexported fields
}

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

func NewSSEClient

func NewSSEClient(instruments octo.Instrumentation, auth octo.Authenticator, pub *stream.Pub, sm *SSEMaster, info octo.Contact, notifications chan []byte, closer chan struct{}) *SSEClient

NewSSEClient returns a new instance of a SSEServer.

func (*SSEClient) Close

func (s *SSEClient) Close() error

Close does nothing.

func (*SSEClient) Send

func (s *SSEClient) Send(data []byte, flush bool) error

Send delivers a giving data to all clients within the connected

func (*SSEClient) SendAll

func (s *SSEClient) SendAll(data []byte, flush bool) error

SendAll delivers data to all subscribed clients.

func (*SSEClient) ServeHTTP

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

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

type SSEMaster

type SSEMaster struct {
	// contains filtered or unexported fields
}

SSEMaster defines a structure which manages multiple SSE(Server-Side Event) and ensures data is being delivered to all.

func NewSSEMaster

func NewSSEMaster(inst octo.Instrumentation, base octo.Contact, auth octo.Authenticator, header map[string]string) *SSEMaster

NewSSEMaster returns a new instance of a SSEMaster.

func (*SSEMaster) Close

func (s *SSEMaster) Close() error

Close ends all connections and awaits all stopping of clients gorountines.

func (*SSEMaster) Register

func (s *SSEMaster) Register(tm stream.StateHandlerType, hmi interface{})

Register registers the handler for a given handler.

func (*SSEMaster) Send

func (s *SSEMaster) Send(data []byte, flush bool) error

Send delivers a giving data to all clients within the connected

func (*SSEMaster) SendAll

func (s *SSEMaster) SendAll(data []byte, flush bool) error

SendAll delivers data to all subscribed clients.

func (*SSEMaster) ServeHTTP

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

ServeHTTP generates a new client for the server sent events based on the

Jump to

Keyboard shortcuts

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