#[non_exhaustive]pub struct AppConfig {Show 35 fields
pub db_uri: String,
pub db_schemas: Vec<String>,
pub db_anon_role: Option<String>,
pub db_pool_size: u32,
pub db_pool_timeout: u64,
pub db_tx_isolation: IsolationLevel,
pub db_prepared_statements: bool,
pub db_extra_search_path: Vec<String>,
pub db_channel: String,
pub db_channel_enabled: bool,
pub db_pre_request: Option<String>,
pub db_max_rows: Option<i64>,
pub db_aggregates_enabled: bool,
pub server_host: String,
pub server_port: u16,
pub server_cors_origins: Vec<String>,
pub max_body_size: usize,
pub server_unix_socket: Option<String>,
pub admin_server_port: Option<u16>,
pub jwt_secret: Option<String>,
pub jwt_secret_is_base64: bool,
pub jwt_aud: Option<String>,
pub jwt_role_claim_key: String,
pub jwt_cache_enabled: bool,
pub jwt_cache_max_lifetime: u64,
pub hasura_admin_secret: Option<String>,
pub hasura_unauthorized_role: Option<String>,
pub openapi_server_proxy_uri: Option<String>,
pub openapi_mode: OpenApiMode,
pub log_level: LogLevel,
pub role_settings: HashMap<String, RoleSettings>,
pub app_settings: HashMap<String, String>,
pub graphql_federation: bool,
pub graphql_type_prefix: Option<String>,
pub compat_mode: bool,
}Expand description
Main application configuration.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.db_uri: StringPostgreSQL connection URI
db_schemas: Vec<String>Schemas to expose via the API
db_anon_role: Option<String>Role for unauthenticated requests
db_pool_size: u32Connection pool size
db_pool_timeout: u64Pool acquisition timeout in seconds
db_tx_isolation: IsolationLevelIsolation level for the transaction every request runs in.
READ COMMITTED unless set, which is PostgreSQL’s own default; a
stricter level is issued as SET TRANSACTION ISOLATION LEVEL on the
request’s transaction.
db_prepared_statements: boolUse prepared statements
db_extra_search_path: Vec<String>Schemas added to the search_path of every request, after the
request’s own schema.
These are not exposed as API endpoints; they are where a function an
exposed one calls, or a type it references, is allowed to live. An
aggregate returning a domain declared elsewhere cannot resolve that
domain without this. public by default, as in PostgREST.
db_channel: StringLISTEN/NOTIFY channel for schema reload
db_channel_enabled: boolEnable NOTIFY-based schema cache reload
db_pre_request: Option<String>Function called on the request’s transaction before its own query, after every setting is applied. Anything it raises aborts the request.
db_max_rows: Option<i64>Maximum rows allowed in a response
db_aggregates_enabled: boolEnable aggregate functions in select.
Off by default, as in PostgREST: an aggregate over a large table costs far more than the request looks like it asks for.
server_host: StringServer host to bind
server_port: u16Server port
server_cors_origins: Vec<String>Origins allowed by CORS.
Empty means every origin is allowed, which is the default and what
PGRST_SERVER_CORS_ORIGINS="*" selects explicitly. A non-empty list
restricts the Access-Control-Allow-Origin response to exactly those
origins; anything else gets no CORS headers and is refused by the
browser.
max_body_size: usizeMaximum accepted request body, in bytes.
The REST handler applies this when it reads the body; the routes that
take a body extractor get it through axum’s DefaultBodyLimit. Before
this was read, the limit in force was a 10 MiB constant in the request
handler, whatever the variable said.
server_unix_socket: Option<String>Listen on a Unix domain socket instead of host and port.
admin_server_port: Option<u16>Serve liveness and readiness on a second port of their own.
jwt_secret: Option<String>JWT secret key (or JWKS URL)
jwt_secret_is_base64: boolJWT secret as base64
jwt_aud: Option<String>JWT audience claim to validate
jwt_role_claim_key: StringJWT claim that contains the role
jwt_cache_enabled: boolCache validated tokens, so a repeated token is not verified again.
jwt_cache_max_lifetime: u64How long a cached validation may be reused, in seconds.
A token’s own exp bounds this; the cache never answers with a token
past its expiry. 0 turns the cache off, as in PostgREST.
hasura_admin_secret: Option<String>The shared secret that authenticates an administrator, and the switch
that makes x-hasura-* headers mean anything at all.
Unset, this server ignores those headers and reads session variables
only from a verified token – because honouring a header nothing
authenticated would let any caller name its own identity, and a policy
reading a value the caller chose is not a policy. Hasura instead treats
an unsecured deployment as wholly administrative; the divergence is
deliberate and is recorded in postrust_auth::hasura.
The role a request falls to when nothing authenticated it. Hasura’s
HASURA_GRAPHQL_UNAUTHORIZED_ROLE; unset means such a request is
refused rather than answered as a stranger.
openapi_server_proxy_uri: Option<String>Address to advertise in the specification’s servers, for when the
server sits behind a reverse proxy and its own address is not the one
clients use.
openapi_mode: OpenApiModeOpenAPI mode: disabled, follow-privileges, ignore-privileges
log_level: LogLevelLog level: crit, error, warn, info, debug
role_settings: HashMap<String, RoleSettings>Per-role settings (isolation level, timeout)
app_settings: HashMap<String, String>App-level settings to expose via GUC
graphql_federation: boolExpose the GraphQL API as an Apollo Federation subgraph.
graphql_type_prefix: Option<String>Namespace applied to generated GraphQL table types and root fields.
compat_mode: boolPostgREST compatibility mode.
When enabled, the REST surface is also served at the root (so canonical
PostgREST paths like /rpc/<name> and /<table> work in addition to
the /api-prefixed paths), and RPC responses are un-wrapped to match
PostgREST’s shape (bare object/scalar for non-set-returning functions,
a top-level array for set-returning ones) instead of the array-wrapped,
function-name-keyed default.
Implementations§
Source§impl AppConfig
impl AppConfig
Sourcepub fn from_env() -> Self
pub fn from_env() -> Self
Load configuration from environment variables.
§Panics
Panics if a boolean environment variable has an unsupported value. Use
Self::try_from_env when the caller can propagate a startup error.
Sourcepub fn try_from_env() -> Result<Self, ConfigError>
pub fn try_from_env() -> Result<Self, ConfigError>
Load configuration from environment variables, rejecting invalid boolean values.
Sourcepub fn try_from_vars<I, K, V>(vars: I) -> Result<Self, ConfigError>
pub fn try_from_vars<I, K, V>(vars: I) -> Result<Self, ConfigError>
Load configuration from name/value pairs spelled as the environment variables are, for a host with no process environment – a Cloudflare Worker reads its bindings instead. Where a name appears twice, the last one wins. Names are matched exactly, case included.
Sourcepub fn default_schema(&self) -> &str
pub fn default_schema(&self) -> &str
Get the default schema (first in the list).
Trait Implementations§
Source§impl<'de> Deserialize<'de> for AppConfig
impl<'de> Deserialize<'de> for AppConfig
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl Freeze for AppConfig
impl RefUnwindSafe for AppConfig
impl Send for AppConfig
impl Sync for AppConfig
impl Unpin for AppConfig
impl UnsafeUnpin for AppConfig
impl UnwindSafe for AppConfig
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more