websockets

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2015 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package websockets implements a WebSocket server by executing a command and piping its input and output through the WebSocket connection.

Index

Constants

This section is empty.

Variables

View Source
var (
	// See CGI spec, 4.1.4
	GatewayInterface string

	// See CGI spec, 4.1.17
	ServerSoftware string
)

Functions

func New

New constructs and configures a new websockets middleware instance.

Types

type WSConfig

type WSConfig struct {
	Path      string
	Command   string
	Arguments []string
	Respawn   bool // TODO: Not used, but parser supports it until we decide on it
}

WSConfig holds the configuration for a single websocket endpoint which may serve multiple websocket connections.

type WebSocket

type WebSocket struct {
	WSConfig
	*http.Request
}

WebSocket represents a web socket server instance. A WebSocket is instantiated for each new websocket request/connection.

func (WebSocket) Handle

func (ws WebSocket) Handle(conn *websocket.Conn)

Handle handles a WebSocket connection. It launches the specified command and streams input and output through the command's stdin and stdout.

type WebSockets

type WebSockets struct {
	// Next is the next HTTP handler in the chain for when the path doesn't match
	Next middleware.Handler

	// Sockets holds all the web socket endpoint configurations
	Sockets []WSConfig
}

WebSockets is a type that holds configuration for the websocket middleware generally, like a list of all the websocket endpoints.

func (WebSockets) ServeHTTP

func (ws WebSockets) ServeHTTP(w http.ResponseWriter, r *http.Request) (int, error)

ServeHTTP converts the HTTP request to a WebSocket connection and serves it up.

Jump to

Keyboard shortcuts

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