http

package
v0.0.0-...-3fab846 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2017 License: Apache-2.0 Imports: 31 Imported by: 0

Documentation

Index

Constants

View Source
const (
	WilcardNamespace = "*"
	BulkMsgType      = "BulkMessage"
)

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

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 (*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

type DefaultWSClientEventHandler struct {
}

func (*DefaultWSClientEventHandler) OnConnected

func (d *DefaultWSClientEventHandler) OnConnected(c *WSAsyncClient)

func (*DefaultWSClientEventHandler) OnDisconnected

func (d *DefaultWSClientEventHandler) OnDisconnected(c *WSAsyncClient)

func (*DefaultWSClientEventHandler) OnMessage

type DefaultWSServerEventHandler

type DefaultWSServerEventHandler struct {
}

func (*DefaultWSServerEventHandler) OnMessage

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

func (*DefaultWSServerEventHandler) OnRegisterClient

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

func (*DefaultWSServerEventHandler) OnUnregisterClient

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

type KeystoneAuthenticationBackend

type KeystoneAuthenticationBackend struct {
	AuthURL string
	Tenant  string
	Domain  string
}

func NewKeystoneAuthenticationBackendFromConfig

func NewKeystoneAuthenticationBackendFromConfig() *KeystoneAuthenticationBackend

func NewKeystoneBackend

func NewKeystoneBackend(authURL string, tenant string, domain 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 (*RestClient) Request

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

type Route

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

type Server

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

func NewServer

func NewServer(host string, serviceType common.ServiceType, addr string, port int, auth AuthenticationBackend) *Server

func NewServerFromConfig

func NewServerFromConfig(serviceType common.ServiceType) (*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 User

type User struct {
	ID   string `mapstructure:"id"`
	Name string `mapstructure:"name"`
}

type WSAsyncClient

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

func NewWSAsyncClient

func NewWSAsyncClient(host string, clientType common.ServiceType, addr string, port int, path string, authClient *AuthenticationClient) *WSAsyncClient

func NewWSAsyncClientFromConfig

func NewWSAsyncClientFromConfig(clientType common.ServiceType, addr string, port int, path string, authClient *AuthenticationClient) *WSAsyncClient

func (*WSAsyncClient) AddEventHandler

func (c *WSAsyncClient) AddEventHandler(h WSClientEventHandler, namespaces []string)

func (*WSAsyncClient) Connect

func (c *WSAsyncClient) Connect()

func (*WSAsyncClient) Disconnect

func (c *WSAsyncClient) Disconnect()

func (*WSAsyncClient) IsConnected

func (c *WSAsyncClient) IsConnected() bool

func (*WSAsyncClient) SendWSMessage

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

type WSAsyncClientPool

type WSAsyncClientPool struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewWSAsyncClientPool

func NewWSAsyncClientPool() *WSAsyncClientPool

func (*WSAsyncClientPool) AddEventHandler

func (a *WSAsyncClientPool) AddEventHandler(h WSClientEventHandler, namespaces []string)

func (*WSAsyncClientPool) AddWSAsyncClient

func (a *WSAsyncClientPool) AddWSAsyncClient(client *WSAsyncClient)

func (*WSAsyncClientPool) BroadcastWSMessage

func (a *WSAsyncClientPool) BroadcastWSMessage(m *WSMessage)

func (*WSAsyncClientPool) ConnectAll

func (a *WSAsyncClientPool) ConnectAll()

func (*WSAsyncClientPool) DisconnectAll

func (a *WSAsyncClientPool) DisconnectAll()

func (*WSAsyncClientPool) MasterClient

func (a *WSAsyncClientPool) MasterClient() *WSAsyncClient

func (*WSAsyncClientPool) OnConnected

func (a *WSAsyncClientPool) OnConnected(c *WSAsyncClient)

func (*WSAsyncClientPool) OnDisconnected

func (a *WSAsyncClientPool) OnDisconnected(c *WSAsyncClient)

func (*WSAsyncClientPool) OnMessage

func (a *WSAsyncClientPool) OnMessage(c *WSAsyncClient, m WSMessage)

func (*WSAsyncClientPool) SendWSMessageToMaster

func (a *WSAsyncClientPool) SendWSMessageToMaster(m *WSMessage)

type WSBulkMessage

type WSBulkMessage []json.RawMessage

type WSClient

type WSClient struct {
	Host       string
	ClientType common.ServiceType
	// contains filtered or unexported fields
}

func (*WSClient) SendWSMessage

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

type WSClientEventHandler

type WSClientEventHandler interface {
	OnMessage(c *WSAsyncClient, m WSMessage)
	OnConnected(c *WSAsyncClient)
	OnDisconnected(c *WSAsyncClient)
}

type WSMessage

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

func NewWSMessage

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

func (WSMessage) Marshal

func (g WSMessage) Marshal() []byte

func (*WSMessage) Reply

func (g *WSMessage) Reply(v interface{}, kind string, status int) *WSMessage

func (WSMessage) String

func (g WSMessage) String() string

type WSServer

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

func NewWSServer

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

func NewWSServerFromConfig

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

func (*WSServer) AddEventHandler

func (s *WSServer) AddEventHandler(h WSServerEventHandler, namespaces []string)

func (*WSServer) BroadcastWSMessage

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

func (*WSServer) GetClientsByType

func (s *WSServer) GetClientsByType(clientType common.ServiceType) (clients []*WSClient)

func (*WSServer) ListenAndServe

func (s *WSServer) ListenAndServe()

func (*WSServer) QueueBroadcastWSMessage

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

func (*WSServer) SendWSMessageTo

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

func (*WSServer) Stop

func (s *WSServer) Stop()

type WSServerEventHandler

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