Skip to main content

Module domain

Module domain 

Source
Available on crate feature domain only.
Expand description

Where ash-domain plugs in — optional, behind the domain feature.

This crate stands alone: resource! over your own structs and storage needs no ash-* crate in the tree at all. This module is the other way in, for a service whose resources the domain already owns.

The division: the domain owns resources, policies and execution; this crate owns the JSON:API wire format. Nothing about a resource is declared twice — attributes, types, relationships and cardinality all come from #[derive(Resource)], and the one thing supplied here is the base path, because the domain does not know it is being served over HTTP.

impl DomainState for App { /* domain, context, mounted schemas */ }

ash_jsonapi::domain_resource! { Todo as "todo" at "/todos", state: App }
ash_jsonapi::api! { operations: [ash_jsonapi::CRUD], resource: Todo, … }

domain_resource! writes the same traits resource! does, so api! serves both kinds of resource identically. Every action runs through the domain — Bound, not around it — so policies, extensions and validation all apply, and error_from turns what comes back into the right status: a denial is a 403, not a 500.

Structs§

DomainInput
A request body on its way to the domain.
Mounted
A resource schema paired with the path it is served under.
MountedSchemas
The schemas a DomainState serves, resolved once at startup.
Probe
A page_query that reads one row past the page.

Traits§

DomainState
Your state, as the ash-domain bridge sees it.

Functions§

error_from
An ash-domain error, as a JSON:API error.
listing_fromhttp and validation
The rows of a probe_query as a Listing.
page_query
A JSON:API collection request as a domain Query.
probe_query
A collection request as a domain query that reads one row too many.