browsers

package
v0.62.14 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2020 License: MPL-2.0 Imports: 4 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) AddBrowser

func (api *API) AddBrowser(ctx context.Context, browser Browser) error

func (*API) DeleteBrowser

func (api *API) DeleteBrowser(ctx context.Context, id string) error

func (*API) GetBrowsers

func (api *API) GetBrowsers(ctx context.Context) ([]*Browser, error)

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) DeleteBrowser

func (db *Database) DeleteBrowser(id string) error

func (*Database) GetBrowsers

func (db *Database) GetBrowsers() (rst []*Browser, err error)

func (*Database) InsertBrowser

func (db *Database) InsertBrowser(browser Browser) (err 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(*p2p.Server) 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