Directive ‘collection’
collection({COLL}) { ... }
Declares that a model exposes a collection of instances. {COLL}
is the name of a class method or scope of the model. Generally, they are certain subsets and/or orders of the models instances.
Collections are exposed by theur URI, which has the form:
https://{HOST}/{PATH}/{RESOURCE}/{COLL}?{PARAMS}
, where
https://{HOST}
is a FQDN.{PATH}
is an optional path segment (seeexpose
parameterunder:
),{RESOURCE}
is name of the resource/model (plural form){COLL}
is the name the class method or scope{PARAMS}
is an optional list of query parameters
Within the block it must be declared which methods the exposed URI accepts. This is done by the directives which have further sub-directives for permissions and custom handlers:
The first one is to retrieve the collection the latter to create a new resource/model instance for that collection.
Note, that the special collecton :all
can be exposed. The URIs https://{HOST}/{PATH}/{RESOURCE}/all
and https://{HOST}/{PATH}/{RESOURCE}
are both responding with all instances of the model.
POST: Does this work with certain scopes and default handler? What is the handler for non-scope collections? Custom handler required?
Windowing
Collections are always delivered partially. If not requested otherwise
the items 0 to max_window (defined in the
global configuration file) are delivered. To request
other ranges the HTTP header Range should be used. More on the
max_window
page.
Example
would yield:
GET https://example.com/people
:
GET https://example.com/people/johns
: