bland-arm-84974
04/29/2023, 3:00 PMtoml
shuttle-runtime = "0.14.0"
axum = "0.6.16"
shuttle-axum = "0.14.0"
tokio = "1.27.0"
serde = "1.0.160"
tower-http = { version = "0.4.0", features = ["cors"] }
shuttle-secrets = "0.14.0"
anyhow = "1.0.70"
sqlx = { version = "0.6.3", features = ["postgres", "runtime-tokio-native-tls"] }
shuttle-shared-db = { version = "0.15.0", features = ["postgres"] }
My main function looks as follows:
rust
#[shuttle_runtime::main]
async fn axum(
#[shuttle_shared_db::Postgres] postgres: Database,
#[shuttle_secrets::Secrets] secrets: SecretStore,
) -> shuttle_axum::ShuttleAxum {
sqlx::migrate!().run(&postgres).await.expect("Error running postgres migrations");
let front_end_url = if let Some(secret) = secrets.get("FRONT_END_URL") {
secret
} else {
return Err(anyhow!("Unable to find secret FRONT_END_URL").into());
};
let cors = CorsLayer::new()
.allow_credentials(true)
.allow_methods([Method::GET])
.allow_origin(front_end_url.parse::<HeaderValue>().unwrap());
let router = Router::new()
.route("/get_json", get(get_json))
.layer(cors);
Ok(router.into())
}
I'm not sure what I'm missing here, is there a dependency I am missing?
Cheersbland-arm-84974
04/29/2023, 3:01 PMDatabase
is currently just type Database = sqlx::PgPool
enough-oil-62271
04/29/2023, 3:11 PMenough-oil-62271
04/29/2023, 3:12 PMbland-arm-84974
04/29/2023, 3:35 PM