Shared handler utilities: ID generation, metadata, body coercion, pagination, search-window construction, error responses.
The VTN's storage layer is canonically ZonedDateTime / Duration.
Wire-format request bodies arrive with string datetimes (parsed JSON);
the coerce-*-body helpers here normalise them to the storage canon
before reaching add-metadata and the storage protocol.
Shared handler utilities: ID generation, metadata, body coercion, pagination, search-window construction, error responses. The VTN's storage layer is canonically `ZonedDateTime` / `Duration`. Wire-format request bodies arrive with string datetimes (parsed JSON); the `coerce-*-body` helpers here normalise them to the storage canon before reaching `add-metadata` and the storage protocol.
(add-metadata body object-type)Add objectMetadata fields to a request body. Sets id, createdDateTime, modificationDateTime (both ZonedDateTime), and objectType.
Add objectMetadata fields to a request body. Sets id, createdDateTime, modificationDateTime (both ZonedDateTime), and objectType.
(bad-request detail)400 Bad Request response.
400 Bad Request response.
(coerce-event-body body)Parse string datetime/duration fields in an EVENT request body to the storage canon (ZonedDateTime / Duration). Idempotent.
Parse string datetime/duration fields in an EVENT request body to the storage canon (ZonedDateTime / Duration). Idempotent.
(coerce-program-body body)Parse string datetime/duration fields in a PROGRAM request body.
Parse string datetime/duration fields in a PROGRAM request body.
(event-search-window query-params)Build a search-window opts map for /events listing.
When dateStart and/or dateEnd are present in the query, returns a map with :date-start / :date-end as ZonedDateTimes (BETWEEN semantics). Otherwise returns a map with :active-from / :active-until set to [now, now + 2 days] for zone-neutral overlap semantics.
Build a search-window opts map for /events listing. When dateStart and/or dateEnd are present in the query, returns a map with :date-start / :date-end as ZonedDateTimes (BETWEEN semantics). Otherwise returns a map with :active-from / :active-until set to [now, now + 2 days] for zone-neutral overlap semantics.
(get-param params k)Get a query param by keyword, falling back to string key. Legba uses string keys for query params.
Get a query param by keyword, falling back to string key. Legba uses string keys for query params.
(new-id)Generate a new object ID (random UUID string).
Generate a new object ID (random UUID string).
(not-found resource-type id)404 Not Found response.
404 Not Found response.
(not-implemented)501 Not Implemented response.
501 Not Implemented response.
(paginate coll {:keys [skip limit]})Apply skip/limit pagination to a collection. Defaults: skip=0, limit=50 (OpenADR max).
Apply skip/limit pagination to a collection. Defaults: skip=0, limit=50 (OpenADR max).
(parse-pagination query-params)Extract skip/limit from query params, coercing to integers. Handles both keyword and string keys (Legba uses string keys).
Extract skip/limit from query params, coercing to integers. Handles both keyword and string keys (Legba uses string keys).
(touch-metadata stored updated)Merge update body into stored object, preserving metadata fields. The update body overrides stored fields, but id, createdDateTime, and objectType are always preserved from stored. modificationDateTime is set to now (ZonedDateTime).
Merge update body into stored object, preserving metadata fields. The update body overrides stored fields, but id, createdDateTime, and objectType are always preserved from stored. modificationDateTime is set to now (ZonedDateTime).
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |