connection

package
v0.0.0-...-ed5be40 Latest Latest
Warning

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

Go to latest
Published: May 29, 2016 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Connection

type Connection struct {
	ID            string `json:"id,omitempty" gorethink:"id"`
	Provider      string `json:"provider" valid:"required" gorethink:"provider"`
	LocalSubject  string `json:"localSubject" valid:"required" gorethink:"localsubject"`
	RemoteSubject string `json:"remoteSubject" valid:"required" gorethink:"remotesubject"`
}

Connection connects an subject S with a token T issued by provider P

func (*Connection) GetID

func (c *Connection) GetID() string

GetID returns the connection's unique identifier.

func (*Connection) GetLocalSubject

func (c *Connection) GetLocalSubject() string

GetLocalSubject returns the connection's local subject, for example "peter".

func (*Connection) GetProvider

func (c *Connection) GetProvider() string

GetProvider returns the connection's provider, for example "Google".

func (*Connection) GetRemoteSubject

func (c *Connection) GetRemoteSubject() string

GetRemoteSubject returns the connection's remote subject, for example "peter@gmail.com".

type HTTPManager

type HTTPManager struct {
	Endpoint *url.URL
	Client   *http.Client
}

func (*HTTPManager) Create

func (m *HTTPManager) Create(connection *Connection) error

func (*HTTPManager) Delete

func (m *HTTPManager) Delete(id string) error

func (*HTTPManager) FindAllByLocalSubject

func (m *HTTPManager) FindAllByLocalSubject(subject string) ([]*Connection, error)

func (*HTTPManager) FindByRemoteSubject

func (m *HTTPManager) FindByRemoteSubject(provider, subject string) (*Connection, error)

func (*HTTPManager) Get

func (m *HTTPManager) Get(id string) (*Connection, error)

type Handler

type Handler struct {
	Manager Manager
	H       herodot.Herodot
	W       firewall.Firewall
}

func (*Handler) Create

func (h *Handler) Create(w http.ResponseWriter, r *http.Request, ps httprouter.Params)

func (*Handler) Delete

func (h *Handler) Delete(w http.ResponseWriter, r *http.Request, ps httprouter.Params)

func (*Handler) FindLocal

func (h *Handler) FindLocal(w http.ResponseWriter, r *http.Request, ps httprouter.Params)

func (*Handler) FindRemote

func (h *Handler) FindRemote(w http.ResponseWriter, r *http.Request, ps httprouter.Params)

func (*Handler) Get

func (*Handler) SetRoutes

func (h *Handler) SetRoutes(r *httprouter.Router)

type Manager

type Manager interface {
	// Create a new connection.
	Create(c *Connection) error

	// Delete an existing connection.
	Delete(id string) error

	// Get an existing connection.
	Get(id string) (*Connection, error)

	FindAllByLocalSubject(subject string) ([]*Connection, error)

	FindByRemoteSubject(provider, subject string) (*Connection, error)
}

Storage defines an interface for storing connections.

type MemoryManager

type MemoryManager struct {
	Connections map[string]*Connection
	sync.RWMutex
}

func NewMemoryManager

func NewMemoryManager() *MemoryManager

func (*MemoryManager) Create

func (m *MemoryManager) Create(c *Connection) error

func (*MemoryManager) Delete

func (m *MemoryManager) Delete(id string) error

func (*MemoryManager) FindAllByLocalSubject

func (m *MemoryManager) FindAllByLocalSubject(subject string) ([]*Connection, error)

func (*MemoryManager) FindByRemoteSubject

func (m *MemoryManager) FindByRemoteSubject(provider, subject string) (*Connection, error)

func (*MemoryManager) Get

func (m *MemoryManager) Get(id string) (*Connection, error)

type RethinkManager

type RethinkManager struct {
	Session *r.Session
	Table   r.Term

	Connections map[string]*Connection

	sync.RWMutex
}

func (*RethinkManager) ColdStart

func (m *RethinkManager) ColdStart() error

func (*RethinkManager) Create

func (m *RethinkManager) Create(c *Connection) error

func (*RethinkManager) Delete

func (m *RethinkManager) Delete(id string) error

func (*RethinkManager) FindAllByLocalSubject

func (m *RethinkManager) FindAllByLocalSubject(subject string) ([]*Connection, error)

func (*RethinkManager) FindByRemoteSubject

func (m *RethinkManager) FindByRemoteSubject(provider, subject string) (*Connection, error)

func (*RethinkManager) Get

func (m *RethinkManager) Get(id string) (*Connection, error)

func (*RethinkManager) Watch

func (m *RethinkManager) Watch(ctx context.Context)

Jump to

Keyboard shortcuts

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