restservice

package module
v0.0.0-...-9159258 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2013 License: MIT Imports: 13 Imported by: 0

README

REST service for straumur

Build Status

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrSaveExisting      = errors.New("Save existing resource")
	ErrUpdateNonExisting = errors.New("Update non-existing resource")
	ErrMissingType       = errors.New("Missing type param")
	ErrInvalidEntity     = errors.New("Invalid entity")
)

Functions

This section is empty.

Types

type Client

type Client struct {
	Id string
	// contains filtered or unexported fields
}

Represents a connected websocket client

func NewClient

func NewClient(ws *websocket.Conn, server *WebSocketServer, uuid string) *Client

func (*Client) Conn

func (c *Client) Conn() *websocket.Conn

func (*Client) Done

func (c *Client) Done()

func (*Client) Listen

func (c *Client) Listen()

func (*Client) Write

func (c *Client) Write(e *straumur.Event)

type FilterPair

type FilterPair struct {
	Id       string
	Query    straumur.Query
	Attempts int
}

type RESTService

type RESTService struct {
	Headers map[string]string
	Store   sessions.Store

	WsServer *WebSocketServer
	// contains filtered or unexported fields
}

func NewRESTService

func NewRESTService(d straumur.DataBackend, errorChan chan error) *RESTService

Creates a new REST dataservice

func (*RESTService) AddSessionIdHeader

func (r *RESTService) AddSessionIdHeader(f func(http.ResponseWriter, *http.Request)) http.HandlerFunc

Appends a unique session id to the request headers

func (*RESTService) Close

func (r *RESTService) Close() error

func (*RESTService) Middleware

func (r *RESTService) Middleware(f func(http.ResponseWriter, *http.Request) (error, int)) http.HandlerFunc

Wraps http.HandlerFunc, adds error response and frequently used headers

func (*RESTService) ServeHTTP

func (r *RESTService) ServeHTTP(w http.ResponseWriter, req *http.Request)

func (*RESTService) Updates

func (r *RESTService) Updates() <-chan *straumur.Event

EventFeed interface

type WebSocketServer

type WebSocketServer struct {
	Filters chan FilterPair
	// contains filtered or unexported fields
}

func NewWebSocketServer

func NewWebSocketServer() *WebSocketServer

Create a new Websocket broadcaster

func (*WebSocketServer) Add

func (s *WebSocketServer) Add(c *Client)

func (*WebSocketServer) Broadcast

func (s *WebSocketServer) Broadcast(e *straumur.Event)

func (*WebSocketServer) Del

func (s *WebSocketServer) Del(c *Client)

func (*WebSocketServer) Done

func (s *WebSocketServer) Done()

func (*WebSocketServer) Err

func (s *WebSocketServer) Err(err error)

func (*WebSocketServer) FindClientById

func (s *WebSocketServer) FindClientById(uuid string) *Client

func (*WebSocketServer) GetHandler

func (s *WebSocketServer) GetHandler() http.Handler

func (*WebSocketServer) Run

func (s *WebSocketServer) Run(ec chan error)

Jump to

Keyboard shortcuts

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