catalog

package
v1.0.0-beta.22 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2021 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ResponseContextURL    = "https://linksmart.eu/thing-directory/context.jsonld"
	ResponseType          = "Catalog"
	ResponseMediaType     = "application/ld+json"
	ResponseJSONMediaType = "application/json"
	// DNS-SD
	DNSSDServiceType    = "_wot._tcp"
	DNSSDServiceSubtype = "_directory" // _directory._sub._wot._tcp
	// Storage backend types
	BackendMemory  = "memory"
	BackendLevelDB = "leveldb"
)
View Source
const (
	MaxPerPage = 100
	// query parameters
	QueryParamPage        = "page"
	QueryParamPerPage     = "per_page"
	QueryParamJSONPath    = "jsonpath"
	QueryParamXPath       = "xpath"
	QueryParamSearchQuery = "query"
	// Deprecated
	QueryParamFetchPath = "fetch"
)

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 ValidationErrorResponse

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

Types

type BadRequestError

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

Bad Request

func (*BadRequestError) Error

func (e *BadRequestError) Error() string

type CatalogController

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

Controller interface

func NewController

func NewController(storage Storage) (CatalogController, error)

type ConflictError

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

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

func (c *Controller) Stop()

Stop the controller

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

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

GetMany lists entries in a paginated catalog format

func (*HTTPAPI) GetValidation

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

GetValidation handler gets validation for the request body

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

func (*HTTPAPI) SearchXPath

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

SearchXPath returns the XPath 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 {
	// contains filtered or unexported fields
}

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 ThingDescriptionPage

type ThingDescriptionPage struct {
	Context string      `json:"@context"`
	Type    string      `json:"@type"`
	Items   interface{} `json:"items"`
	Page    int         `json:"page"`
	PerPage int         `json:"perPage"`
	Total   int         `json:"total"`
}

type ValidationError

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

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