Documentation
¶
Index ¶
- func AddEndpoint(r *mux.Router, endpoint EndpointInterface, primal data.PrimalInterface)
- func BuildHTTPRequest(url string, path string, method string, data []byte) (request http.Request, err error)
- func GetURLByPublicKey(primal data.PrimalInterface, recipient string) (string, error)
- type Body
- type Broker
- type ConversationCreateBody
- type ConversationInviteBody
- type ConversationPrivateEndpoint
- func (m ConversationPrivateEndpoint) GetPublicKeyByURL(url string) (string, error)
- func (m ConversationPrivateEndpoint) Handler() func(w http.ResponseWriter, r *http.Request)
- func (m ConversationPrivateEndpoint) Init()
- func (m ConversationPrivateEndpoint) Methods() []string
- func (m ConversationPrivateEndpoint) Path() string
- func (m ConversationPrivateEndpoint) RequiresPrimal() bool
- type ConversationPublicEndpoint
- type DeviceBody
- type DevicePrivateEndpoint
- type DevicePublicEndpoint
- type EndpointInterface
- type InfoPrivateEndpoint
- type MessageBody
- type MessageCreateBody
- type MessagePrivateEndpoint
- type MessagePublicEndpoint
- type MockedDevicesDb
- func (m *MockedDevicesDb) ConfirmRequest(request data.DeviceRequest, sharedKey string) (*data.Device, error)
- func (m *MockedDevicesDb) DeleteDevice(device data.Device) error
- func (m *MockedDevicesDb) DeleteRequest(request data.DeviceRequest) error
- func (m *MockedDevicesDb) GetDeviceByPublicKey(publicKey string) *data.Device
- func (m *MockedDevicesDb) GetDeviceByURL(url string) *data.Device
- func (m *MockedDevicesDb) GetDevices() []data.Device
- func (m *MockedDevicesDb) GetRequestByURL(url string) *data.DeviceRequest
- func (m *MockedDevicesDb) GetRequests() []data.DeviceRequest
- func (m *MockedDevicesDb) StoreDevice(device data.Device) error
- func (m *MockedDevicesDb) StoreRequest(request data.DeviceRequest) error
- type MockedMessageDb
- func (m *MockedMessageDb) GetConversationByID(conversationID string) *data.Conversation
- func (m *MockedMessageDb) GetConversations() []data.Conversation
- func (m *MockedMessageDb) GetConversationsByRecipient(recipient string) []data.Conversation
- func (m *MockedMessageDb) GetNewestMessages(conversationID string, count int) []data.Message
- func (m *MockedMessageDb) RefreshConversationLastUpdate(conversationID string, timestamp string) error
- func (m *MockedMessageDb) StoreConversation(conversation data.Conversation) error
- func (m *MockedMessageDb) StoreMessage(message data.Message) error
- type MockedPrimalInterface
- func (m *MockedPrimalInterface) ComputeSharedKey(publicKey string) string
- func (m *MockedPrimalInterface) GetDevices() []data.Device
- func (m *MockedPrimalInterface) GetMiddleware(next http.Handler) func(w http.ResponseWriter, r *http.Request)
- func (m *MockedPrimalInterface) GetOfflineQueue() data.OfflineSqliteDB
- func (m *MockedPrimalInterface) GetPublicKey() string
- func (m *MockedPrimalInterface) GetPublicURL() string
- func (m *MockedPrimalInterface) IsURLOnline(url string) bool
- func (m *MockedPrimalInterface) Notify(event data.BrokerEvent)
- func (m *MockedPrimalInterface) Send(request http.Request, encrypt bool) (*http.Response, error)
- func (m *MockedPrimalInterface) SendPendingRequests(publicKey string)
- type RequestBody
- type RequestPrivateEndpoint
- type RequestPublicEndpoint
- type TestingRouter
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 GetURLByPublicKey ¶
func GetURLByPublicKey(primal data.PrimalInterface, recipient string) (string, error)
Types ¶
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 }
type ConversationCreateBody ¶
type ConversationInviteBody ¶
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 ¶
func (m ConversationPrivateEndpoint) Handler() func(w http.ResponseWriter, r *http.Request)
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 ¶
func (m ConversationPrivateEndpoint) Path() string
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 ¶
func (m ConversationPublicEndpoint) Path() string
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 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 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) SendPendingRequests ¶
func (m *MockedPrimalInterface) SendPendingRequests(publicKey string)
type RequestBody ¶
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 ¶
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