handlers

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2017 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const ScriptContent string = `` /* 416-byte string literal not displayed */

Variables

This section is empty.

Functions

func NewFileServer added in v0.2.0

func NewFileServer(h http.Handler) http.Handler

NewFileServer creates a new middleware for single page applications

func NewInjectingHandler

func NewInjectingHandler(h http.Handler) http.Handler

NewInjectingHandler returns a http.Handler that intercepts the original response and modifies it

Types

type Broker

type Broker struct {

	// Channel into which messages are pushed to be broadcast out
	// to attahed clients.
	//
	Messages chan string
	// contains filtered or unexported fields
}

Broker is responsible for keeping a list of which clients (browsers) are currently attached and broadcasting events (messages) to those clients.

func NewBroker

func NewBroker() *Broker

NewBroker creates a new broker instance

func (*Broker) ServeHTTP

func (b *Broker) ServeHTTP(w http.ResponseWriter, r *http.Request)

This Broker method handles and HTTP request at the "/events/" URL.

func (*Broker) Start

func (b *Broker) Start()

This Broker method starts a new goroutine. It handles the addition & removal of clients, as well as the broadcasting of messages out to clients that are currently attached.

type FileWatcher

type FileWatcher struct {
	Handler    http.Handler
	Broker     *Broker
	Watcher    chan notify.EventInfo
	Extensions []string
}

FileWatcher recursively watches the served directory for changes

func NewFileWatcher

func NewFileWatcher(dir, ext string, h http.Handler) *FileWatcher

NewFileWatcher returns a new file watcher

type InjectMiddleware

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

InjectMiddleware intercepts the response and modifies it in some way

func (*InjectMiddleware) ServeHTTP

func (m *InjectMiddleware) ServeHTTP(w http.ResponseWriter, r *http.Request)

type SPAMiddleware added in v0.2.0

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

SPAMiddleware intercepts the response and modifies it in some way

func (*SPAMiddleware) ServeHTTP added in v0.2.0

func (m *SPAMiddleware) ServeHTTP(w http.ResponseWriter, r *http.Request)

type TransformationFunc

type TransformationFunc func(r io.Reader) (string, error)

TransformationFunc is the function used to transform the original response

Jump to

Keyboard shortcuts

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