Documentation ¶
Index ¶
- Constants
- func ErrorResponse(w http.ResponseWriter, code int, msg ...interface{})
- func ProblemDetailsResponse(w http.ResponseWriter, pd wot.ProblemDetails)
- func ThingExpires(tr *wot.ThingRegistration) *time.Time
- func ThingRegistration(td ThingDescription) *wot.ThingRegistration
- func ThingTTL(tr *wot.ThingRegistration) *float64
- func ValidationErrorResponse(w http.ResponseWriter, validationIssues []wot.ValidationError)
- type BadRequestError
- type CatalogController
- type ConflictError
- type Controller
- type EventListener
- type HTTPAPI
- func (a *HTTPAPI) Delete(w http.ResponseWriter, req *http.Request)
- func (a *HTTPAPI) Get(w http.ResponseWriter, req *http.Request)
- func (a *HTTPAPI) List(w http.ResponseWriter, req *http.Request)
- func (a *HTTPAPI) Patch(w http.ResponseWriter, req *http.Request)
- func (a *HTTPAPI) Post(w http.ResponseWriter, req *http.Request)
- func (a *HTTPAPI) Put(w http.ResponseWriter, req *http.Request)
- func (a *HTTPAPI) SearchJSONPath(w http.ResponseWriter, req *http.Request)
- type LevelDBStorage
- type NotFoundError
- type Storage
- type ThingDescription
- type ValidationError
- type ValidationResult
Constants ¶
const ( // Storage backend types BackendMemory = "memory" BackendLevelDB = "leveldb" )
const ( // query parameters QueryParamOffset = "offset" QueryParamLimit = "limit" QueryParamJSONPath = "jsonpath" QueryParamSearchQuery = "query" )
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)
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
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