catalog

package
v1.0.0-beta.26 Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2022 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Storage backend types
	BackendMemory  = "memory"
	BackendLevelDB = "leveldb"
)
View Source
const (
	// query parameters
	QueryParamOffset      = "offset"
	QueryParamLimit       = "limit"
	QueryParamJSONPath    = "jsonpath"
	QueryParamSearchQuery = "query"
)
View Source
const (
	MaxLimit = 100
)

Variables

This section is empty.

Functions

func ErrorResponse

func ErrorResponse(w http.ResponseWriter, code int, msg ...interface{})

ErrorResponse writes error to HTTP ResponseWriter

func ProblemDetailsResponse

func ProblemDetailsResponse(w http.ResponseWriter, pd wot.ProblemDetails)

ErrorResponse writes error to HTTP ResponseWriter

func ThingExpires

func ThingExpires(tr *wot.ThingRegistration) *time.Time

func ThingRegistration

func ThingRegistration(td ThingDescription) *wot.ThingRegistration

func ThingTTL

func ThingTTL(tr *wot.ThingRegistration) *float64

func ValidationErrorResponse

func ValidationErrorResponse(w http.ResponseWriter, validationIssues []wot.ValidationError)

Types

type BadRequestError

type BadRequestError struct{ S string }

Bad Request

func (*BadRequestError) Error

func (e *BadRequestError) Error() string

type CatalogController

type CatalogController interface {
	Stop()
	AddSubscriber(listener EventListener)
	// contains filtered or unexported methods
}

Controller interface

func NewController

func NewController(storage Storage) (CatalogController, error)

type ConflictError

type ConflictError struct{ S string }

Conflict (non-unique id, assignment to read-only data)

func (*ConflictError) Error

func (e *ConflictError) Error() string

type Controller

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

func (*Controller) AddSubscriber

func (c *Controller) AddSubscriber(listener EventListener)

func (*Controller) Stop

func (c *Controller) Stop()

Stop the controller

type EventListener

type EventListener interface {
	CreateHandler(new ThingDescription) error
	UpdateHandler(old ThingDescription, new ThingDescription) error
	DeleteHandler(old ThingDescription) error
}

EventListener interface that listens to TDD events.

type HTTPAPI

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

func NewHTTPAPI

func NewHTTPAPI(controller CatalogController, version string) *HTTPAPI

func (*HTTPAPI) Delete

func (a *HTTPAPI) Delete(w http.ResponseWriter, req *http.Request)

Delete removes one item

func (*HTTPAPI) Get

func (a *HTTPAPI) Get(w http.ResponseWriter, req *http.Request)

Get handler get one item

func (*HTTPAPI) List

func (a *HTTPAPI) List(w http.ResponseWriter, req *http.Request)

List lists entries in paginated format or as a stream

func (*HTTPAPI) Patch

func (a *HTTPAPI) Patch(w http.ResponseWriter, req *http.Request)

Patch updates parts or all of an existing item (Response: StatusOK)

func (*HTTPAPI) Post

func (a *HTTPAPI) Post(w http.ResponseWriter, req *http.Request)

Post handler creates one item

func (*HTTPAPI) Put

func (a *HTTPAPI) Put(w http.ResponseWriter, req *http.Request)

Put handler updates an existing item (Response: StatusOK) If the item does not exist, a new one will be created with the given id (Response: StatusCreated)

func (*HTTPAPI) SearchJSONPath

func (a *HTTPAPI) SearchJSONPath(w http.ResponseWriter, req *http.Request)

SearchJSONPath returns the JSONPath query result

type LevelDBStorage

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

LevelDB storage

func (*LevelDBStorage) Close

func (s *LevelDBStorage) Close()

type NotFoundError

type NotFoundError struct{ S string }

Not Found

func (*NotFoundError) Error

func (e *NotFoundError) Error() string

type Storage

type Storage interface {
	Close()
	// contains filtered or unexported methods
}

Storage interface

func NewLevelDBStorage

func NewLevelDBStorage(dsn string, opts *opt.Options) (Storage, error)

type ThingDescription

type ThingDescription = map[string]interface{}

type ValidationError

type ValidationError struct {
	ValidationErrors []wot.ValidationError
}

Validation error (HTTP Bad Request)

func (*ValidationError) Error

func (e *ValidationError) Error() string

type ValidationResult

type ValidationResult struct {
	Valid  bool     `json:"valid"`
	Errors []string `json:"errors"`
}

Jump to

Keyboard shortcuts

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