browsers

package
v0.182.37 Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2024 License: MPL-2.0 Imports: 6 Imported by: 0

README

Browsers Service

Browser service provides read/write API for browser object.

To enable include browsers config part and add browsers to APIModules:

{
  "BrowsersConfig": {
    "Enabled": true,
  },
  APIModules: "browsers"
}

API

Enabling service will expose three additional methods:

browsers_addBrowser

Stores browser in the database. All fields are specified below:

{
  "browser-id": "1",
  "name": "first",
  "timestamp": 10,
  "dapp?": true,
  "history-index": 1,
  "history": [
    "one",
    "two"
  ]
}
browsers_getBrowsers

Reads all browsers, returns in the format specified above. List is sorted by timestamp.

browsers_deleteBrowser

Delete browser from database. Accepts browser id.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type API

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

API is class with methods available over RPC.

func NewAPI

func NewAPI(db *Database) *API

func (*API) DeleteBookmark added in v0.63.10

func (api *API) DeleteBookmark(ctx context.Context, url string) error

func (*API) GetBookmarks added in v0.63.10

func (api *API) GetBookmarks(ctx context.Context) ([]*Bookmark, error)

func (*API) RemoveBookmark added in v0.94.4

func (api *API) RemoveBookmark(ctx context.Context, url string) error

func (*API) StoreBookmark added in v0.63.10

func (api *API) StoreBookmark(ctx context.Context, bookmark Bookmark) (Bookmark, error)

func (*API) UpdateBookmark added in v0.63.10

func (api *API) UpdateBookmark(ctx context.Context, originalURL string, bookmark Bookmark) error

type Bookmark added in v0.63.10

type Bookmark struct {
	URL       string `json:"url"`
	Name      string `json:"name"`
	ImageURL  string `json:"imageUrl"`
	Removed   bool   `json:"removed"`
	Clock     uint64 `json:"-"` //used to sync
	DeletedAt uint64 `json:"deletedAt,omitempty"`
}

type BookmarksType added in v0.63.10

type BookmarksType string

type Browser

type Browser struct {
	ID           string   `json:"browser-id"`
	Name         string   `json:"name"`
	Timestamp    uint64   `json:"timestamp"`
	Dapp         bool     `json:"dapp?"`
	HistoryIndex int      `json:"history-index"`
	History      []string `json:"history,omitempty"`
}

type Database

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

Database sql wrapper for operations with browser objects.

func NewDB

func NewDB(db *sql.DB) *Database

func (Database) Close

func (db Database) Close() error

Close closes database.

func (*Database) DeleteBookmark added in v0.63.10

func (db *Database) DeleteBookmark(url string) error

func (*Database) GetBookmarks added in v0.63.10

func (db *Database) GetBookmarks() ([]*Bookmark, error)

func (*Database) RemoveBookmark added in v0.94.4

func (db *Database) RemoveBookmark(url string) error

func (*Database) StoreBookmark added in v0.63.10

func (db *Database) StoreBookmark(bookmark Bookmark) (Bookmark, error)

func (*Database) StoreBookmarkWithoutFetchIcon added in v0.94.4

func (db *Database) StoreBookmarkWithoutFetchIcon(bookmark *Bookmark, tx *sql.Tx) (err error)

func (*Database) StoreSyncBookmarks added in v0.94.4

func (db *Database) StoreSyncBookmarks(bookmarks []*Bookmark) ([]*Bookmark, error)

func (*Database) UpdateBookmark added in v0.63.10

func (db *Database) UpdateBookmark(originalURL string, bookmark Bookmark) error

type Service

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

Service is a browsers service.

func NewService

func NewService(db *Database) *Service

NewService initializes service instance.

func (*Service) APIs

func (s *Service) APIs() []rpc.API

APIs returns list of available RPC APIs.

func (*Service) Protocols

func (s *Service) Protocols() []p2p.Protocol

Protocols returns list of p2p protocols.

func (*Service) Start

func (s *Service) Start() error

Start a service.

func (*Service) Stop

func (s *Service) Stop() error

Stop a service.

Jump to

Keyboard shortcuts

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