http

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2016 License: Apache-2.0 Imports: 30 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Namespace = "WSServer"
)

Variables

View Source
var (
	WrongCredentials error = errors.New("Wrong credentials")
)

Functions

This section is empty.

Types

type AuthenticationBackend

type AuthenticationBackend interface {
	Authenticate(username string, password string) (string, error)
	Wrap(wrapped auth.AuthenticatedHandlerFunc) http.HandlerFunc
}

func NewAuthenticationBackendFromConfig

func NewAuthenticationBackendFromConfig() (AuthenticationBackend, error)

type AuthenticationClient

type AuthenticationClient struct {
	Addr      string
	Port      int
	AuthToken string
	// contains filtered or unexported fields
}

func NewAuthenticationClient

func NewAuthenticationClient(addr string, port int, authOptions *AuthenticationOpts) *AuthenticationClient

func (*AuthenticationClient) Authenticate

func (c *AuthenticationClient) Authenticate() error

func (*AuthenticationClient) Authenticated

func (c *AuthenticationClient) Authenticated() bool

func (*AuthenticationClient) Cookie

func (c *AuthenticationClient) Cookie() *http.Cookie

func (*AuthenticationClient) SetHeaders

func (c *AuthenticationClient) SetHeaders(headers http.Header)

type AuthenticationOpts

type AuthenticationOpts struct {
	Username string
	Password string
}

type BasicAuthenticationBackend

type BasicAuthenticationBackend struct {
	*auth.BasicAuth
}

func NewBasicAuthenticationBackend added in v0.4.0

func NewBasicAuthenticationBackend(file string) (*BasicAuthenticationBackend, error)

func NewBasicAuthenticationBackendFromConfig

func NewBasicAuthenticationBackendFromConfig() (*BasicAuthenticationBackend, error)

func (*BasicAuthenticationBackend) Authenticate

func (b *BasicAuthenticationBackend) Authenticate(username string, password string) (string, error)

func (*BasicAuthenticationBackend) Wrap

func (b *BasicAuthenticationBackend) Wrap(wrapped auth.AuthenticatedHandlerFunc) http.HandlerFunc

type CrudClient

type CrudClient struct {
	RestClient
	Root string
}

func NewCrudClient

func NewCrudClient(addr string, port int, authOpts *AuthenticationOpts, root string) *CrudClient

func NewCrudClientFromConfig

func NewCrudClientFromConfig(authOpts *AuthenticationOpts, root string) *CrudClient

func (*CrudClient) Create

func (c *CrudClient) Create(resource string, value interface{}) error

func (*CrudClient) Delete

func (c *CrudClient) Delete(resource string, id string) error

func (*CrudClient) Get

func (c *CrudClient) Get(resource string, id string, value interface{}) error

func (*CrudClient) List

func (c *CrudClient) List(resource string, values interface{}) error

func (*CrudClient) Update

func (c *CrudClient) Update(resource string, id string, value interface{}) error

type DefaultWSClientEventHandler added in v0.4.0

type DefaultWSClientEventHandler struct {
}

func (*DefaultWSClientEventHandler) OnConnected added in v0.4.0

func (d *DefaultWSClientEventHandler) OnConnected()

func (*DefaultWSClientEventHandler) OnDisconnected added in v0.4.0

func (d *DefaultWSClientEventHandler) OnDisconnected()

func (*DefaultWSClientEventHandler) OnMessage added in v0.4.0

func (d *DefaultWSClientEventHandler) OnMessage(m WSMessage)

type DefaultWSServerEventHandler added in v0.4.0

type DefaultWSServerEventHandler struct {
}

func (*DefaultWSServerEventHandler) OnMessage added in v0.4.0

func (d *DefaultWSServerEventHandler) OnMessage(c *WSClient, m WSMessage)

func (*DefaultWSServerEventHandler) OnRegisterClient added in v0.4.0

func (d *DefaultWSServerEventHandler) OnRegisterClient(c *WSClient)

func (*DefaultWSServerEventHandler) OnUnregisterClient added in v0.4.0

func (d *DefaultWSServerEventHandler) OnUnregisterClient(c *WSClient)

type KeystoneAuthenticationBackend

type KeystoneAuthenticationBackend struct {
	AuthURL string
	Tenant  string
}

func NewKeystoneAuthenticationBackendFromConfig

func NewKeystoneAuthenticationBackendFromConfig() *KeystoneAuthenticationBackend

func NewKeystoneBackend

func NewKeystoneBackend(authURL string, tenant string) *KeystoneAuthenticationBackend

func (*KeystoneAuthenticationBackend) Authenticate

func (b *KeystoneAuthenticationBackend) Authenticate(username string, password string) (string, error)

func (*KeystoneAuthenticationBackend) CheckUser

func (*KeystoneAuthenticationBackend) Wrap

type NoAuthenticationBackend

type NoAuthenticationBackend struct {
}

func NewNoAuthenticationBackend

func NewNoAuthenticationBackend() *NoAuthenticationBackend

func (*NoAuthenticationBackend) Authenticate

func (h *NoAuthenticationBackend) Authenticate(username string, password string) (string, error)

func (*NoAuthenticationBackend) Wrap

func (h *NoAuthenticationBackend) Wrap(wrapped auth.AuthenticatedHandlerFunc) http.HandlerFunc

type PathPrefix

type PathPrefix string

type RestClient

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

func NewRestClient

func NewRestClient(addr string, port int, authOptions *AuthenticationOpts) *RestClient

func NewRestClientFromConfig

func NewRestClientFromConfig(authOptions *AuthenticationOpts) *RestClient

func (*RestClient) Request

func (c *RestClient) Request(method, path string, body io.Reader) (*http.Response, error)

type Route

type Route struct {
	Name        string
	Method      string
	Path        interface{}
	HandlerFunc auth.AuthenticatedHandlerFunc
}

type Server

type Server struct {
	Service string
	Router  *mux.Router
	Addr    string
	Port    int
	Auth    AuthenticationBackend
	// contains filtered or unexported fields
}

func NewServer

func NewServer(s string, a string, p int, auth AuthenticationBackend) *Server

func NewServerFromConfig

func NewServerFromConfig(s string) (*Server, error)

func (*Server) HandleFunc

func (s *Server) HandleFunc(path string, f auth.AuthenticatedHandlerFunc)

func (*Server) ListenAndServe

func (s *Server) ListenAndServe()

func (*Server) RegisterRoutes

func (s *Server) RegisterRoutes(routes []Route)

func (*Server) Stop

func (s *Server) Stop()

type WSAsyncClient added in v0.4.0

type WSAsyncClient struct {
	sync.RWMutex
	Addr       string
	Port       int
	Path       string
	AuthClient *AuthenticationClient
	// contains filtered or unexported fields
}

func NewWSAsyncClient added in v0.4.0

func NewWSAsyncClient(hostID string, clientType string, addr string, port int, path string, authClient *AuthenticationClient) (*WSAsyncClient, error)

func NewWSAsyncClientFromConfig added in v0.4.0

func NewWSAsyncClientFromConfig(clientType string, addr string, port int, path string, authClient *AuthenticationClient) (*WSAsyncClient, error)

func (*WSAsyncClient) AddEventHandler added in v0.4.0

func (c *WSAsyncClient) AddEventHandler(h WSClientEventHandler)

func (*WSAsyncClient) Connect added in v0.4.0

func (c *WSAsyncClient) Connect()

func (*WSAsyncClient) Disconnect added in v0.4.0

func (c *WSAsyncClient) Disconnect()

func (*WSAsyncClient) IsConnected added in v0.4.0

func (c *WSAsyncClient) IsConnected() bool

func (*WSAsyncClient) SendWSMessage added in v0.4.0

func (c *WSAsyncClient) SendWSMessage(m *WSMessage)

type WSClient added in v0.4.0

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

func (*WSClient) GetHostInfo added in v0.5.0

func (c *WSClient) GetHostInfo() (string, string)

func (*WSClient) SendWSMessage added in v0.4.0

func (c *WSClient) SendWSMessage(msg *WSMessage)

type WSClientEventHandler added in v0.4.0

type WSClientEventHandler interface {
	OnMessage(m WSMessage)
	OnConnected()
	OnDisconnected()
}

type WSMessage added in v0.4.0

type WSMessage struct {
	Namespace string
	Type      string
	UUID      string `json:",omitempty"`
	Obj       *json.RawMessage
}

func NewWSMessage added in v0.5.0

func NewWSMessage(ns string, tp string, v interface{}, uuids ...string) *WSMessage

func (WSMessage) Marshal added in v0.4.0

func (g WSMessage) Marshal() []byte

func (*WSMessage) Reply added in v0.5.0

func (g *WSMessage) Reply(v interface{}) *WSMessage

func (WSMessage) String added in v0.4.0

func (g WSMessage) String() string

type WSServer added in v0.4.0

type WSServer struct {
	sync.RWMutex
	DefaultWSServerEventHandler
	Server *Server
	// contains filtered or unexported fields
}

func NewWSServer added in v0.4.0

func NewWSServer(server *Server, pongWait time.Duration, endpoint string) *WSServer

func NewWSServerFromConfig added in v0.4.0

func NewWSServerFromConfig(server *Server, endpoint string) *WSServer

func (*WSServer) AddEventHandler added in v0.4.0

func (s *WSServer) AddEventHandler(h WSServerEventHandler)

func (*WSServer) BroadcastWSMessage added in v0.4.0

func (s *WSServer) BroadcastWSMessage(msg *WSMessage)

func (*WSServer) GetClientsByType added in v0.5.0

func (s *WSServer) GetClientsByType(kind string) (clients []*WSClient)

func (*WSServer) ListenAndServe added in v0.4.0

func (s *WSServer) ListenAndServe()

func (*WSServer) SendWSMessageTo added in v0.4.0

func (s *WSServer) SendWSMessageTo(msg *WSMessage, host string) bool

func (*WSServer) Stop added in v0.4.0

func (s *WSServer) Stop()

type WSServerEventHandler added in v0.4.0

type WSServerEventHandler interface {
	OnMessage(c *WSClient, m WSMessage)
	OnRegisterClient(c *WSClient)
	OnUnregisterClient(c *WSClient)
}

Jump to

Keyboard shortcuts

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