Expand description
Component configuration variables.
Component variables must be defined in the application
manifest, in the [component.<name>.variables] section.
Component variables typically use template syntax to
derive values from application variables, which are
the only variables that may be overridden directly (for
example, on the Spin command line).
§Examples
Get the value of a component variable.
let region = spin_sdk::variables::get("region_id")?;
let regional_url = format!("https://{region}.db.example.com");Fail gracefully if a variable is not set.
use spin_sdk::variables::Error;
let favourite = match spin_sdk::variables::get("favourite") {
Ok(value) => value,
Err(Error::Undefined(_)) => "not playing favourites".to_owned(),
Err(e) => anyhow::bail!(e),
};Enums§
- Error
- The set of errors which may be raised by functions in this interface.
Functions§
- get
- Get the value of a component variable.