pub struct Config { /* private fields */ }Expand description
Fusion Stack’s settings, mirroring config/api.php in the PHP package.
Implementations§
Source§impl Config
impl Config
Sourcepub fn new() -> Self
pub fn new() -> Self
The defaults: request IDs on, every path’s errors rendered as JSON:API, versioning off.
Sourcepub const fn request_ids(self, enabled: bool) -> Self
pub const fn request_ids(self, enabled: bool) -> Self
Whether responses carry X-Request-Id and errors meta.request_id.
Sourcepub fn error_paths<I: IntoIterator<Item = S>, S: Into<String>>(
self,
paths: I,
) -> Self
pub fn error_paths<I: IntoIterator<Item = S>, S: Into<String>>( self, paths: I, ) -> Self
The paths whose errors render as JSON:API error documents, such as v1/*. * matches anything.
Sourcepub fn resource(self, resource: Resource) -> Self
pub fn resource(self, resource: Resource) -> Self
Registers a JSON:API resource type, for queries, includes and the OpenAPI document.
Sourcepub const fn page_sizes(self, default: u64, max: u64) -> Self
pub const fn page_sizes(self, default: u64, max: u64) -> Self
The page size when a request sets none (api.query.page_size, 25), and the largest a
request may ask for (api.query.max_page_size, 100).
Sourcepub const fn max_include_depth(self, depth: usize) -> Self
pub const fn max_include_depth(self, depth: usize) -> Self
How deep include paths may nest (api.query.max_include_depth, 3).
Whether successful GET responses carry a weak ETag and answer If-None-Match with a 304
(api.http_cache.etags, on).
Sourcepub fn cache_control(self, directives: Option<&str>) -> Self
pub fn cache_control(self, directives: Option<&str>) -> Self
The Cache-Control of successful GET responses whose route sets none with
CacheControl (api.http_cache.cache_control, private, no-cache). None leaves the
handler’s own, or the default no-cache, private.
Sourcepub fn vary<I: IntoIterator<Item = S>, S: Into<String>>(
self,
headers: I,
) -> Self
pub fn vary<I: IntoIterator<Item = S>, S: Into<String>>( self, headers: I, ) -> Self
The request headers GET and HEAD responses vary on (api.http_cache.vary,
Api-Version, Authorization, Accept). Api-Version is left out while versioning is off.
Sourcepub const fn response_cache(self, enabled: bool) -> Self
pub const fn response_cache(self, enabled: bool) -> Self
Whether routes with CacheResponse are cached (api.response_cache.enabled, on).
Sourcepub fn response_cache_store(self, store: Option<&str>) -> Self
pub fn response_cache_store(self, store: Option<&str>) -> Self
The cache store that keeps cached responses (api.response_cache.store), or None for
the default store. Pass the same name to response_cache::flush_in.
Sourcepub const fn auth(self, enabled: bool) -> Self
pub const fn auth(self, enabled: bool) -> Self
Whether requests are resolved to API clients (api.auth.enabled, on). Off, every request
is a guest’s.
Sourcepub fn client_resolver(self, resolver: ClientResolver) -> Self
pub fn client_resolver(self, resolver: ClientResolver) -> Self
Your own authentication, tried before the crate’s API keys, as api.auth.guards and
api.auth.resolvers add guards in PHP. See auth::resolver.
Sourcepub const fn track_usage(self, enabled: bool) -> Self
pub const fn track_usage(self, enabled: bool) -> Self
Whether each client’s versions are recorded in api_version_usage, once a day per version
(api.versions.track_usage, on). Needs the database feature.
Sourcepub fn endpoint(self, route: &str, endpoint: Endpoint) -> Self
pub fn endpoint(self, route: &str, endpoint: Endpoint) -> Self
Describes an endpoint for the OpenAPI document, by its method and URI, such as
GET /v1/orders.
Sourcepub fn docs(self, docs: Docs) -> Self
pub fn docs(self, docs: Docs) -> Self
The API reference and changelog pages that docs::routes mounts (api.docs).
Sourcepub fn openapi_info(self, title: &str, description: Option<&str>) -> Self
pub fn openapi_info(self, title: &str, description: Option<&str>) -> Self
The OpenAPI document’s title and description (api.openapi.title, the app’s name, and
api.openapi.description).
Sourcepub fn openapi_servers<I: IntoIterator<Item = S>, S: Into<String>>(
self,
urls: I,
) -> Self
pub fn openapi_servers<I: IntoIterator<Item = S>, S: Into<String>>( self, urls: I, ) -> Self
The servers the OpenAPI document lists (api.openapi.servers, APP_URL).
Sourcepub fn openapi_version(self, version: &str) -> Self
pub fn openapi_version(self, version: &str) -> Self
The document’s version while API versioning is off (api.openapi.version, 1.0.0).
Sourcepub fn error_codes<I: IntoIterator<Item = Arc<dyn ErrorCode>>>(
self,
codes: I,
) -> Self
pub fn error_codes<I: IntoIterator<Item = Arc<dyn ErrorCode>>>( self, codes: I, ) -> Self
The application’s own error codes, listed in the OpenAPI document with the package’s
(api.openapi.error_codes).
Sourcepub const fn rate_limit(self, enabled: bool) -> Self
pub const fn rate_limit(self, enabled: bool) -> Self
Whether requests are rate limited (api.rate_limit.enabled, on).
Sourcepub fn rate_limit_tier(self, name: &str, tier: impl Into<Option<Tier>>) -> Self
pub fn rate_limit_tier(self, name: &str, tier: impl Into<Option<Tier>>) -> Self
Sets a rate limit tier (api.rate_limit.tiers), or removes it with None. Guests use
guest (60 requests a minute), and clients their own tier or default (300 a minute).
Sourcepub const fn idempotency(self, enabled: bool) -> Self
pub const fn idempotency(self, enabled: bool) -> Self
Whether requests with an Idempotency-Key run once (api.idempotency.enabled, on).
Sourcepub fn idempotent_methods<I: IntoIterator<Item = S>, S: Into<String>>(
self,
methods: I,
) -> Self
pub fn idempotent_methods<I: IntoIterator<Item = S>, S: Into<String>>( self, methods: I, ) -> Self
The methods idempotency keys apply to (api.idempotency.methods, POST, PATCH and DELETE).
Sourcepub const fn idempotency_times(self, ttl: u64, lock_seconds: u64) -> Self
pub const fn idempotency_times(self, ttl: u64, lock_seconds: u64) -> Self
How long responses are kept for replays, in seconds (api.idempotency.ttl, a day), and how
long a request holds its key while it runs (api.idempotency.lock_seconds, 60).
Sourcepub fn idempotency_store(self, store: Option<&str>) -> Self
pub fn idempotency_store(self, store: Option<&str>) -> Self
The cache store that keeps idempotent responses and locks (api.idempotency.store), or
None for the default store. It must support atomic locks.