Documentation ¶
Index ¶
- Constants
- func ErrorResponse(w http.ResponseWriter, code int, msg ...interface{})
- func ProblemDetailsResponse(w http.ResponseWriter, pd wot.ProblemDetails)
- func ValidationErrorResponse(w http.ResponseWriter, validationIssues []wot.ValidationError)
- type BadRequestError
- type CatalogController
- type ConflictError
- type Controller
- 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) GetMany(w http.ResponseWriter, req *http.Request)
- func (a *HTTPAPI) GetValidation(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)
- func (a *HTTPAPI) SearchXPath(w http.ResponseWriter, req *http.Request)
- type LevelDBStorage
- type NotFoundError
- type Storage
- type ThingDescription
- type ThingDescriptionPage
- type ValidationError
- type ValidationResult
Constants ¶
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" )
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
}
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
type ThingDescription ¶
type ThingDescription = map[string]interface{}
type ThingDescriptionPage ¶
type ValidationError ¶
type ValidationError struct {
// contains filtered or unexported fields
}
Validation error (HTTP Bad Request)
func (*ValidationError) Error ¶
func (e *ValidationError) Error() string