Documentation ¶
Index ¶
- func Dispatch(reader io.Reader, writer io.Writer) error
- func GetPayload[T Payload](msg NativeMessage) (T, error)
- type AddBookPayload
- type AddFolderPayload
- type AddTagsPayload
- type BookDTO
- type BookPayload
- type BooksPayload
- type ErrorPayload
- type ListBooksPayload
- type ListTagsPayload
- type MessageKind
- type NativeMessage
- type Payload
- type RemoveBookPayload
- type RemoveFolderPayload
- type RemoveTagsPayload
- type TagsPayload
- type UpdateBookPayload
- type UpdateFolderPayload
- type VoidPayload
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetPayload ¶
func GetPayload[T Payload](msg NativeMessage) (T, error)
GetPayload gets the underlying payload in a message.
Types ¶
type AddBookPayload ¶
type AddBookPayload struct { DB null.NullString `json:"db"` URL string `json:"url"` Name null.NullString `json:"name"` Description null.NullString `json:"description"` ParentID null.NullString `json:"parentId"` Tags []string `json:"tags"` }
AddBookPayload is a payload for a request to add a bookmark.
type AddFolderPayload ¶
type AddFolderPayload struct { DB null.NullString `json:"db"` Name string `json:"name"` ParentID null.NullString `json:"parentId"` }
AddFolderPayload is a payload for a request to add a folder.
type AddTagsPayload ¶
type AddTagsPayload struct { DB null.NullString `json:"db"` ID string `json:"id"` Tags []string `json:"tags"` }
AddTagsPayload is a payload for a request to add tags.
type BookDTO ¶
type BookDTO struct { ID string `json:"id"` URL null.NullString `json:"url"` Name string `json:"name"` Description null.NullString `json:"description"` ParentID null.NullString `json:"parentId"` IsFolder bool `json:"isFolder"` ParentName null.NullString `json:"parentName"` Tags []string `json:"tags"` }
BookDTO is a bookmark or folder that can be marshalled into JSON.
type BookPayload ¶
type BookPayload struct {
Book BookDTO `json:"book"`
}
BookPayload is a payload for a response with a bookmark/folder in it.
type BooksPayload ¶
type BooksPayload struct {
Books []BookDTO `json:"books"`
}
BooksPayload is a payload for a response with bookmarks/folders in it.
type ErrorPayload ¶
type ErrorPayload struct {
Error string `json:"error"`
}
ErrorPayload is a payload for a response with an error in it.
type ListBooksPayload ¶
type ListBooksPayload struct { DB null.NullString `json:"db"` IncludeBookmarks bool `json:"includeBookmarks"` IncludeFolders bool `json:"includeFolders"` ParentID null.NullString `json:"parentID"` WithoutParentID bool `json:"withoutParentID"` Query null.NullString `json:"query"` Tags []string `json:"tags"` After null.NullString `json:"after"` Order string `json:"order"` Direction string `json:"direction"` First null.NullInt64 `json:"first"` }
ListBooksPayload is a payload for a request to list bookmarks.
type ListTagsPayload ¶
type ListTagsPayload struct { DB null.NullString `json:"db"` Query null.NullString `json:"query"` After null.NullString `json:"after"` Direction string `json:"direction"` First null.NullInt64 `json:"first"` }
ListTagsPayload is a payload for a request to list tags.
type MessageKind ¶
type MessageKind string
MessageKind denotes the kind of message that was sent to or received from a browser extension.
const ( MessageKindError MessageKind = "error" // message contains an error that occurred MessageKindBooks MessageKind = "books" // message contains zero or more books MessageKindBook MessageKind = "book" // message contains a single book MessageKindVoid MessageKind = "void" // message contains nothing MessageKindTags MessageKind = "tags" // message contains zero or more tags MessageKindAddBook MessageKind = "add-book" // message is a request to add a bookmark MessageKindAddFolder MessageKind = "add-folder" // message is a request to add a bookmark MessageKindAddTags MessageKind = "add-tags" // message is a request to add tags MessageKindListBooks MessageKind = "list-books" // message is a request to list books MessageKindListTags MessageKind = "list-tags" // message is a request to list tags MessageKindRemoveBook MessageKind = "remove-book" // message is a request to remove a bookmark MessageKindRemoveFolder MessageKind = "remove-folder" // message is a request to remove a folder MessageKindRemoveTags MessageKind = "remove-tags" // message is a request to remove tags from a bookmark MessageKindUpdateBook MessageKind = "update-book" // message is a request to update a bookmark MessageKindUpdateFolder MessageKind = "update-folder" // message is a request to update a folder )
type NativeMessage ¶
type NativeMessage struct { Kind MessageKind `json:"kind"` // denotes what kind of message this is Payload string `json:"payload"` // a JSON payload that is different depending on the MessageKind }
NativeMessage is a message sent to or received from a browser extension.
func PayloadToMessage ¶
func PayloadToMessage[T Payload](kind MessageKind, payload T) (NativeMessage, error)
PayloadToMessage converts a payload to a NativeMessage.
func ReceiveMessage ¶
func ReceiveMessage(reader io.Reader) (NativeMessage, error)
ReceiveMessage receives a message from a browser extension.
func (NativeMessage) SendMessage ¶
func (msg NativeMessage) SendMessage(writer io.Writer) error
SendMessage sends a message to a browser extension.
type Payload ¶
type Payload interface { AddBookPayload | AddFolderPayload | AddTagsPayload | ListBooksPayload | ListTagsPayload | RemoveBookPayload | RemoveFolderPayload | RemoveTagsPayload | UpdateBookPayload | UpdateFolderPayload | ErrorPayload | BooksPayload | BookPayload | TagsPayload | VoidPayload }
Payload are the payloads that a message can have.
type RemoveBookPayload ¶
type RemoveBookPayload struct { DB null.NullString `json:"db"` ID string `json:"id"` }
RemoveBookPayload is a payload for a request to delete a bookmark.
type RemoveFolderPayload ¶
type RemoveFolderPayload struct { DB null.NullString `json:"db"` ID string `json:"id"` }
RemoveFolderPayload is a payload for a request to delete a folder.
type RemoveTagsPayload ¶
type RemoveTagsPayload struct { DB null.NullString `json:"db"` ID string `json:"id"` Tags []string `json:"tags"` }
RemoveTagsPayload is a payload for a request to remove tags.
type TagsPayload ¶
type TagsPayload struct {
Tags []string `json:"tags"`
}
TagsPayload is a payload for a response with tags in it.
type UpdateBookPayload ¶
type UpdateBookPayload struct { DB null.NullString `json:"db"` ID string `json:"id"` Name null.NullString `json:"name"` URL null.NullString `json:"url"` Description null.NullString `json:"description"` ParentID null.NullString `json:"parentId"` RemoveDescription bool `json:"removeDescription"` RemoveParentID bool `json:"removeParentID"` }
UpdateBookPayload is a payload for a request to update a bookmark.
type UpdateFolderPayload ¶
type UpdateFolderPayload struct { DB null.NullString `json:"db"` ID string `json:"id"` Name null.NullString `json:"name"` ParentID null.NullString `json:"parentId"` RemoveParentID bool `json:"removeParentID"` }
UpdateBookPayload is a payload for a request to update a folder.
type VoidPayload ¶
type VoidPayload struct{}
VoidPayload is a payload for a response with nothing in it.