api

package
v0.0.0-...-48b1a76 Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2022 License: BSD-3-Clause Imports: 9 Imported by: 0

Documentation

Overview

Package api implements http REST API compatible with xBrowserSync service.

Handlers implemented by api package are completly indepedent of used http router. It is up to implementing person to choose proper http router.

See xBrowserSync documentation for further information about what it is and how it works.

Index

Constants

This section is empty.

Variables

View Source
var ErrBookmarksNotFound = errors.New("bookmarks with given id has been not found")

ErrBookmarksNotFound is returned by BookmarksStorage when there is no bookmarks with given ID in storage.

Functions

func Bookmarks

func Bookmarks(storage BookmarksStorage, params QueryParameters) http.HandlerFunc

Bookmarks retrieves the bookmark sync corresponding to the provided sync ID.

func CreateBookmarks

func CreateBookmarks(storage BookmarksStorage) http.HandlerFunc

CreateBookmarks creates a new (empty) bookmark sync and returns the corresponding ID.

func Info

func Info(location, msg, version string) http.HandlerFunc

Info retrieves information describing the xBrowserSync service.

func LastUpdated

func LastUpdated(storage BookmarksStorage, params QueryParameters) http.HandlerFunc

LastUpdated retrieves the bookmark sync last updated timestamp corresponding to the provided sync ID.

func UpdateBookmarks

func UpdateBookmarks(storage BookmarksStorage, params QueryParameters) http.HandlerFunc

UpdateBookmarks updates the bookmark sync data corresponding to the provided sync ID with the provided encrypted bookmarks data.

func Version

func Version(storage BookmarksStorage, params QueryParameters) http.HandlerFunc

Version retrieves the bookmark sync version number of the xBrowserSync client used to create the bookmarks sync corresponding to the provided sync ID.

Types

type BookmarksStorage

type BookmarksStorage interface {
	// SetBookmarks method stores given encrypted Bookmarks
	// in database.
	SetBookmarks(ctx context.Context, b models.Bookmarks) error

	// GetBookmarks retrieves encrypted Bookmarks with given id
	// from database.
	GetBookmarks(ctx context.Context, id string) (*models.Bookmarks, error)
}

BookmarksStorage describes methods required for storing and retrieving bookmarks from data source. It has to be thread safe.

type QueryParameters

type QueryParameters interface {
	// ID returns 32 character alphanumeric sync ID used
	// by client.
	ID(*http.Request) string
}

QueryParameters help to determine specific bookmarks.

Jump to

Keyboard shortcuts

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