Add ADMIN_KEY variable to context

このコミットが含まれているのは:
Lucien Cartier-Tilet 2023-01-15 22:51:22 +01:00
コミット 8c62727ec9
署名者: phundrak
GPGキーID: BD7789E705CB8DCA
2個のファイルの変更23行の追加0行の削除

ファイルの表示

@ -1,3 +1,5 @@
ADMIN_KEY=
ORDABOK_HOSTS=https://example.com # if empty or unset, CORS will allow all origins
# Database

ファイルの表示

@ -3,11 +3,32 @@ use crate::db::Database;
use tracing::info;
macro_rules! from_env {
($varname:expr) => {
std::env::var($varname)
.expect(format!("{} must be set!", $varname).as_str())
};
}
#[derive(Debug, Clone)]
pub struct OtherEnvVar {
pub admin_key: String,
}
impl Default for OtherEnvVar {
fn default() -> Self {
Self {
admin_key: from_env!("ADMIN_KEY")
}
}
}
#[derive(Default, Debug, Clone)]
pub struct Context {
pub db: Database,
pub appwrite: APVariables,
pub user_auth: bool,
pub other_vars: OtherEnvVar
}
impl Context {