api

package
v0.0.0-...-64ed5c8 Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2020 License: GPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddEndpoint

func AddEndpoint(r *mux.Router, endpoint EndpointInterface, primal data.PrimalInterface)

AddEndpoint add the endpoint implementation to the router, using primal middleware if required

func BuildHTTPRequest

func BuildHTTPRequest(url string, path string, method string, data []byte) (request http.Request, err error)

func GetURLByPublicKey

func GetURLByPublicKey(primal data.PrimalInterface, recipient string) (string, error)

Types

type Body

type Body interface {
	// contains filtered or unexported methods
}

type Broker

type Broker struct {

	// Events are pushed to this channel by the main events-gathering routine
	Notifier chan []byte
	// contains filtered or unexported fields
}

func NewBroker

func NewBroker() (broker *Broker)

func (*Broker) ServeHTTP

func (broker *Broker) ServeHTTP(rw http.ResponseWriter, req *http.Request)

type ConversationCreateBody

type ConversationCreateBody struct {
	Name       string   `json:"name"`
	Recipients []string `json:"recipients"`
}

type ConversationInviteBody

type ConversationInviteBody struct {
	ID         string   `json:"id"`
	Name       string   `json:"name"`
	Recipients []string `json:"recipients"`
}

type ConversationPrivateEndpoint

type ConversationPrivateEndpoint struct {
	Db     data.MessageDB
	Primal data.PrimalInterface
}

func (ConversationPrivateEndpoint) GetPublicKeyByURL

func (m ConversationPrivateEndpoint) GetPublicKeyByURL(url string) (string, error)

func (ConversationPrivateEndpoint) Handler

Handler handle requests

func (ConversationPrivateEndpoint) Init

func (m ConversationPrivateEndpoint) Init()

Init initialize the devices module

func (ConversationPrivateEndpoint) Methods

func (m ConversationPrivateEndpoint) Methods() []string

Methods POST -> send | PUT -> confirm

func (ConversationPrivateEndpoint) Path

Path this modules will manage the endpoint /request/{action} POST -> send | PUT -> confirm

func (ConversationPrivateEndpoint) RequiresPrimal

func (m ConversationPrivateEndpoint) RequiresPrimal() bool

RequiresPrimal no, this is primal

type ConversationPublicEndpoint

type ConversationPublicEndpoint struct {
	Db     data.MessageDB
	Primal data.PrimalInterface
}

func (ConversationPublicEndpoint) Handler

func (m ConversationPublicEndpoint) Handler() func(w http.ResponseWriter, r *http.Request)

Handler handle requests

func (ConversationPublicEndpoint) Init

func (m ConversationPublicEndpoint) Init()

Init initialize the devices module

func (ConversationPublicEndpoint) Methods

func (m ConversationPublicEndpoint) Methods() []string

Methods POST -> send | PUT -> confirm

func (ConversationPublicEndpoint) Path

Path this modules will manage the endpoint /request/{action} POST -> send | PUT -> confirm

func (ConversationPublicEndpoint) RequiresPrimal

func (m ConversationPublicEndpoint) RequiresPrimal() bool

RequiresPrimal no, this is primal

type DeviceBody

type DeviceBody struct {
	URL       string `json:"url"`
	Alias     string `json:"alias"`
	PublicKey string `json:"public_key"`
}

type DevicePrivateEndpoint

type DevicePrivateEndpoint struct {
	Db       data.DevicesDatabase
	Presence *data.Presence
	Primal   data.PrimalInterface
}

func (DevicePrivateEndpoint) Handler

func (m DevicePrivateEndpoint) Handler() func(w http.ResponseWriter, r *http.Request)

Handler handle requests

func (DevicePrivateEndpoint) Init

func (m DevicePrivateEndpoint) Init()

Init initialize the devices module

func (DevicePrivateEndpoint) Methods

func (m DevicePrivateEndpoint) Methods() []string

Methods POST -> send | PUT -> confirm

func (DevicePrivateEndpoint) Path

func (m DevicePrivateEndpoint) Path() string

Path this modules will manage the endpoint /request/{action} POST -> send | PUT -> confirm

func (DevicePrivateEndpoint) RequiresPrimal

func (m DevicePrivateEndpoint) RequiresPrimal() bool

RequiresPrimal no, this is primal

type DevicePublicEndpoint

type DevicePublicEndpoint struct {
	Presence *data.Presence
	Primal   data.PrimalInterface
}

func (DevicePublicEndpoint) Handler

func (m DevicePublicEndpoint) Handler() func(w http.ResponseWriter, r *http.Request)

Handler handle requests

func (DevicePublicEndpoint) Init

func (m DevicePublicEndpoint) Init()

Init initialize the devices module

func (DevicePublicEndpoint) Methods

func (m DevicePublicEndpoint) Methods() []string

Methods POST -> send | PUT -> confirm

func (DevicePublicEndpoint) Path

func (m DevicePublicEndpoint) Path() string

Path this modules will manage the endpoint /request/{action} POST -> send | PUT -> confirm

func (DevicePublicEndpoint) RequiresPrimal

func (m DevicePublicEndpoint) RequiresPrimal() bool

RequiresPrimal no, this is primal

type EndpointInterface

type EndpointInterface interface {
	Init()                                                 // this method will initialize the module
	Path() string                                          // the path handled
	Handler() func(w http.ResponseWriter, r *http.Request) // the handler itself
	Methods() []string                                     // GET/POST/...
	RequiresPrimal() bool                                  // if this module requires the primal middleware
}

type InfoPrivateEndpoint

type InfoPrivateEndpoint struct {
	Primal data.PrimalInterface
}

func (InfoPrivateEndpoint) Handler

func (m InfoPrivateEndpoint) Handler() func(w http.ResponseWriter, r *http.Request)

Handler handle requests

func (InfoPrivateEndpoint) Init

func (m InfoPrivateEndpoint) Init()

func (InfoPrivateEndpoint) Methods

func (m InfoPrivateEndpoint) Methods() []string

Methods POST -> send | PUT -> confirm

func (InfoPrivateEndpoint) Path

func (m InfoPrivateEndpoint) Path() string

func (InfoPrivateEndpoint) RequiresPrimal

func (m InfoPrivateEndpoint) RequiresPrimal() bool

RequiresPrimal no

type MessageBody

type MessageBody struct {
	ID        string `json:"id"`
	Recipient string `json:"recipient"`
	Content   string `json:"message"`
	Timestamp string `json:"timestamp"`
}

type MessageCreateBody

type MessageCreateBody struct {
	Content string `json:"content"`
}

type MessagePrivateEndpoint

type MessagePrivateEndpoint struct {
	Db     data.MessageDB
	Primal data.PrimalInterface
}

func (MessagePrivateEndpoint) Handler

func (m MessagePrivateEndpoint) Handler() func(w http.ResponseWriter, r *http.Request)

Handler handle requests

func (MessagePrivateEndpoint) Init

func (m MessagePrivateEndpoint) Init()

Init initialize the devices module

func (MessagePrivateEndpoint) Methods

func (m MessagePrivateEndpoint) Methods() []string

Methods POST -> send | PUT -> confirm

func (MessagePrivateEndpoint) Path

func (m MessagePrivateEndpoint) Path() string

Path this modules will manage the endpoint /request/{action} POST -> send | PUT -> confirm

func (MessagePrivateEndpoint) RequiresPrimal

func (m MessagePrivateEndpoint) RequiresPrimal() bool

RequiresPrimal no, this is primal

type MessagePublicEndpoint

type MessagePublicEndpoint struct {
	Db     data.MessageDB
	Primal data.PrimalInterface
}

func (MessagePublicEndpoint) Handler

func (m MessagePublicEndpoint) Handler() func(w http.ResponseWriter, r *http.Request)

Handler handle requests

func (MessagePublicEndpoint) Init

func (m MessagePublicEndpoint) Init()

Init initialize the devices module

func (MessagePublicEndpoint) Methods

func (m MessagePublicEndpoint) Methods() []string

Methods POST -> send | PUT -> confirm

func (MessagePublicEndpoint) Path

func (m MessagePublicEndpoint) Path() string

Path this modules will manage the endpoint /request/{action} POST -> send | PUT -> confirm

func (MessagePublicEndpoint) RequiresPrimal

func (m MessagePublicEndpoint) RequiresPrimal() bool

RequiresPrimal no, this is primal

type MockedDevicesDb

type MockedDevicesDb struct {
	ConfirmedRequest data.DeviceRequest
	// contains filtered or unexported fields
}

func (*MockedDevicesDb) ConfirmRequest

func (m *MockedDevicesDb) ConfirmRequest(request data.DeviceRequest, sharedKey string) (*data.Device, error)

func (*MockedDevicesDb) DeleteDevice

func (m *MockedDevicesDb) DeleteDevice(device data.Device) error

func (*MockedDevicesDb) DeleteRequest

func (m *MockedDevicesDb) DeleteRequest(request data.DeviceRequest) error

func (*MockedDevicesDb) GetDeviceByPublicKey

func (m *MockedDevicesDb) GetDeviceByPublicKey(publicKey string) *data.Device

func (*MockedDevicesDb) GetDeviceByURL

func (m *MockedDevicesDb) GetDeviceByURL(url string) *data.Device

func (*MockedDevicesDb) GetDevices

func (m *MockedDevicesDb) GetDevices() []data.Device

func (*MockedDevicesDb) GetRequestByURL

func (m *MockedDevicesDb) GetRequestByURL(url string) *data.DeviceRequest

func (*MockedDevicesDb) GetRequests

func (m *MockedDevicesDb) GetRequests() []data.DeviceRequest

func (*MockedDevicesDb) StoreDevice

func (m *MockedDevicesDb) StoreDevice(device data.Device) error

func (*MockedDevicesDb) StoreRequest

func (m *MockedDevicesDb) StoreRequest(request data.DeviceRequest) error

type MockedMessageDb

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

func (*MockedMessageDb) GetConversationByID

func (m *MockedMessageDb) GetConversationByID(conversationID string) *data.Conversation

func (*MockedMessageDb) GetConversations

func (m *MockedMessageDb) GetConversations() []data.Conversation

func (*MockedMessageDb) GetConversationsByRecipient

func (m *MockedMessageDb) GetConversationsByRecipient(recipient string) []data.Conversation

func (*MockedMessageDb) GetNewestMessages

func (m *MockedMessageDb) GetNewestMessages(conversationID string, count int) []data.Message

func (*MockedMessageDb) RefreshConversationLastUpdate

func (m *MockedMessageDb) RefreshConversationLastUpdate(conversationID string, timestamp string) error

func (*MockedMessageDb) StoreConversation

func (m *MockedMessageDb) StoreConversation(conversation data.Conversation) error

func (*MockedMessageDb) StoreMessage

func (m *MockedMessageDb) StoreMessage(message data.Message) error

type MockedPrimalInterface

type MockedPrimalInterface struct {
	Event   *data.BrokerEvent
	Request http.Request
}

func (*MockedPrimalInterface) ComputeSharedKey

func (m *MockedPrimalInterface) ComputeSharedKey(publicKey string) string

func (*MockedPrimalInterface) GetDevices

func (m *MockedPrimalInterface) GetDevices() []data.Device

func (*MockedPrimalInterface) GetMiddleware

func (m *MockedPrimalInterface) GetMiddleware(next http.Handler) func(w http.ResponseWriter, r *http.Request)

func (*MockedPrimalInterface) GetOfflineQueue

func (m *MockedPrimalInterface) GetOfflineQueue() data.OfflineSqliteDB

func (*MockedPrimalInterface) GetPublicKey

func (m *MockedPrimalInterface) GetPublicKey() string

func (*MockedPrimalInterface) GetPublicURL

func (m *MockedPrimalInterface) GetPublicURL() string

func (*MockedPrimalInterface) IsURLOnline

func (m *MockedPrimalInterface) IsURLOnline(url string) bool

func (*MockedPrimalInterface) Notify

func (m *MockedPrimalInterface) Notify(event data.BrokerEvent)

func (*MockedPrimalInterface) Send

func (m *MockedPrimalInterface) Send(request http.Request, encrypt bool) (*http.Response, error)

func (*MockedPrimalInterface) SendPendingRequests

func (m *MockedPrimalInterface) SendPendingRequests(publicKey string)

type RequestBody

type RequestBody struct {
	URL       string `json:"url"`
	PublicKey string `json:"public_key"`
	Alias     string `json:"alias"`
}

type RequestPrivateEndpoint

type RequestPrivateEndpoint struct {
	Db     data.DevicesDatabase
	Primal data.PrimalInterface
}

func (RequestPrivateEndpoint) Handler

func (m RequestPrivateEndpoint) Handler() func(w http.ResponseWriter, r *http.Request)

Handler handle requests

func (RequestPrivateEndpoint) Init

func (m RequestPrivateEndpoint) Init()

func (RequestPrivateEndpoint) Methods

func (m RequestPrivateEndpoint) Methods() []string

Methods POST -> send | PUT -> confirm

func (RequestPrivateEndpoint) Path

func (m RequestPrivateEndpoint) Path() string

Path this modules will manage the endpoint /request/{action} POST -> send | PUT -> confirm

func (RequestPrivateEndpoint) RequiresPrimal

func (m RequestPrivateEndpoint) RequiresPrimal() bool

RequiresPrimal no, this is primal

type RequestPublicEndpoint

type RequestPublicEndpoint struct {
	Db     data.DevicesDatabase
	Primal data.PrimalInterface
}

func (RequestPublicEndpoint) Handler

func (m RequestPublicEndpoint) Handler() func(w http.ResponseWriter, r *http.Request)

Handler handle requests

func (RequestPublicEndpoint) Init

func (m RequestPublicEndpoint) Init()

Init initialize the request module

func (RequestPublicEndpoint) Methods

func (m RequestPublicEndpoint) Methods() []string

Methods POST -> send | PUT -> confirm

func (RequestPublicEndpoint) Path

func (m RequestPublicEndpoint) Path() string

Path this modules will manage the endpoint /request/{action} POST -> send | PUT -> confirm

func (RequestPublicEndpoint) RequiresPrimal

func (m RequestPublicEndpoint) RequiresPrimal() bool

RequiresPrimal no, this is primal

type TestingRouter

type TestingRouter struct {
	Router *mux.Router
}

func (*TestingRouter) CheckResponseCode

func (tr *TestingRouter) CheckResponseCode(t *testing.T, expected, actual int)

func (*TestingRouter) ExecuteRequest

func (tr *TestingRouter) ExecuteRequest(req *http.Request) *httptest.ResponseRecorder

Jump to

Keyboard shortcuts

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