package
0.0.0-20250226171102-4db14ec44d68
Repository: https://github.com/cozy/cozy-stack.git
Documentation: pkg.go.dev

# Functions

BadGateway returns a 502 formatted error.
BadJSON returns a 400 formatted error meaning the json input is malformed.
BadRequest returns a 400 formatted error.
Bind is used to unmarshal an input JSONApi document.
BindCompound is used to unmarshal an compound input JSONApi document.
BindRelations extracts a Relationships request ( a list of ResourceIdentifier).
Conflict returns a 409 formatted error representing a conflict.
Data can be called to send an answer with a JSON-API document containing a single object as data.
DataError can be called to send an error answer with a JSON-API document containing a single value error.
DataErrorList can be called to send an error answer with a JSON-API document containing multiple errors.
DataList can be called to send an multiple-value answer with a JSON-API document contains multiple objects.
DataListWithMeta can be called to send a list of Objects with meta like a count, useful to indicate total number of results with pagination.
DataRelations can be called to send a Relations page, a list of ResourceIdentifier.
Errorf creates a new generic Error with detail build as Sprintf.
ExtractPaginationCursor creates a Cursor from context Query.
Forbidden returns a 403 Forbidden error formatted when an action is fobidden.
InternalServerError returns a 500 formatted error.
InvalidAttribute returns a 422 formatted error when an attribute is invalid.
InvalidParameter returns a 422 formatted error when an HTTP or Query-String parameter is invalid.
MarshalObject serializes an Object to JSON.
MethodNotAllowed returns a 405 formatted error.
NewError creates a new generic Error.
NotFound returns a 404 formatted error.
PaginationCursorToParams transforms a Cursor into url.Values the url.Values contains only keys page[limit] & page[cursor] if the cursor is Done, the values will be empty.
PreconditionFailed returns a 412 formatted error when an expectation from an HTTP header is not matched.
Unauthorized returns a 401 formatted error.
WriteData can be called to write an answer with a JSON-API document containing a single object as data into an io.Writer.

# Constants

ContentType is the official mime-type for JSON-API.

# Structs

Document is JSON-API document, identified by the mediatype application/vnd.api+json See http://jsonapi.org/format/#document-structure.
Error objects provide additional information about problems encountered while performing an operation.
LinksList is the common links used in JSON-API for the top-level or a resource object See http://jsonapi.org/format/#document-links.
Meta is a container for the couchdb revision and the total number of items, in JSON-API land.
ObjectMarshalling is a JSON-API object See http://jsonapi.org/format/#document-resource-objects.
Relationship is a resource linkage, as described in JSON-API See http://jsonapi.org/format/#document-resource-object-relationships Data can be a single ResourceIdentifier for to-one relationships, or an array of them for to-many relationships.
SourceError contains references to the source of the error.

# Interfaces

Object is an interface to serialize something to a JSON-API Object.

# Type aliases

ErrorList is just an array of error objects.
RelationshipMap is a map of relationships See http://jsonapi.org/format/#document-resource-object-relationships.