Spaces:
Runtime error
Runtime error
Update src/main.rs
Browse files- src/main.rs +10 -7
src/main.rs
CHANGED
|
@@ -19,9 +19,8 @@ use sqlx::{PgPool, prelude::FromRow};
|
|
| 19 |
|
| 20 |
#[actix_web::main]
|
| 21 |
async fn main() -> std::io::Result<()> {
|
| 22 |
-
println!("START APP");
|
| 23 |
dotenvy::dotenv().ok();
|
| 24 |
-
|
| 25 |
let pool = match db().await {
|
| 26 |
Ok(pool) => {
|
| 27 |
println!("Database connected!");
|
|
@@ -35,11 +34,15 @@ async fn main() -> std::io::Result<()> {
|
|
| 35 |
));
|
| 36 |
}
|
| 37 |
};
|
| 38 |
-
println!("DATABASE CONNECTED");
|
| 39 |
-
let key = Key::generate();
|
| 40 |
-
let session_store = RedisSessionStore::new("rediss://default:gQAAAAAAAhlpAAIgcDE1NTRjMzkzODkwYWM0YTRlYjNiOTRkY2FmNWIzOTRlYg@liked-honeybee-137577.upstash.io:6379").await.unwrap();
|
| 41 |
|
| 42 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 43 |
HttpServer::new(move || {
|
| 44 |
App::new()
|
| 45 |
.app_data(Data::new(pool.clone()))
|
|
@@ -178,7 +181,7 @@ async fn protected(req: HttpRequest) -> impl Responder {
|
|
| 178 |
|
| 179 |
async fn auth(
|
| 180 |
id: Option<Identity>,
|
| 181 |
-
|
| 182 |
next: Next<BoxBody>,
|
| 183 |
) -> Result<ServiceResponse<BoxBody>, Error> {
|
| 184 |
if let Some(id) = id {
|
|
|
|
| 19 |
|
| 20 |
#[actix_web::main]
|
| 21 |
async fn main() -> std::io::Result<()> {
|
|
|
|
| 22 |
dotenvy::dotenv().ok();
|
| 23 |
+
|
| 24 |
let pool = match db().await {
|
| 25 |
Ok(pool) => {
|
| 26 |
println!("Database connected!");
|
|
|
|
| 34 |
));
|
| 35 |
}
|
| 36 |
};
|
|
|
|
|
|
|
|
|
|
| 37 |
|
| 38 |
+
let secret_key = std::env::var("SECRET_KEY").expect("SECRET_KEY not found");
|
| 39 |
+
|
| 40 |
+
let key = Key::from(secret_key.as_bytes());
|
| 41 |
+
|
| 42 |
+
let redis_url = std::env::var("REDIS_URL").expect("REDIS_URL not found");
|
| 43 |
+
|
| 44 |
+
let session_store = RedisSessionStore::new(redis_url).await.unwrap();
|
| 45 |
+
|
| 46 |
HttpServer::new(move || {
|
| 47 |
App::new()
|
| 48 |
.app_data(Data::new(pool.clone()))
|
|
|
|
| 181 |
|
| 182 |
async fn auth(
|
| 183 |
id: Option<Identity>,
|
| 184 |
+
req: ServiceRequest,
|
| 185 |
next: Next<BoxBody>,
|
| 186 |
) -> Result<ServiceResponse<BoxBody>, Error> {
|
| 187 |
if let Some(id) = id {
|