Skip to content

Commit

Permalink
Debug workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
johnshaughnessy committed Nov 7, 2023
1 parent 3d076b2 commit 3775adb
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion docker/prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ services:
track-server:
image: us-central1-docker.pkg.dev/hubs-dev-333333/ocho-osai/johnshaughnessy/track/track-server
volumes:
- ./track:/track
- ./:/track
4 changes: 2 additions & 2 deletions server/src/api/weights.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ pub async fn post_weights(
}

pub async fn get_weights(pool: web::Data<Pool<ConnectionManager<PgConnection>>>) -> impl Responder {
log::info!("get_weights");
let mut conn = pool.get().unwrap();

match server::models::weights::read_weights(&mut conn) {
Ok(weights) => HttpResponse::Ok().json(weights),
Err(e) => {
HttpResponse::InternalServerError().body(format!("Error retrieving weights: {:?}", e))
}
// Err(_) => HttpResponse::InternalServerError().body("Error retrieving weights."),
} // Err(_) => HttpResponse::InternalServerError().body("Error retrieving weights."),
}
}

Expand Down
18 changes: 9 additions & 9 deletions server/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,34 +34,34 @@ async fn main() -> std::io::Result<()> {
.allowed_header(http::header::CONTENT_TYPE)
.max_age(3600),
ref x if x == "prod" => Cors::default()
.allowed_origin("https://www.example.com")
.allow_any_origin()
.allowed_methods(vec!["GET", "POST", "PATCH", "DELETE"])
.allowed_headers(vec![http::header::AUTHORIZATION, http::header::ACCEPT])
.allowed_header(http::header::CONTENT_TYPE)
.max_age(3600),
_ => panic!("APP_ENV must be set to either 'dev' or 'prod'"),
};

println!("APP_ENV: {:?}", std::env::var("APP_ENV"));
println!("cors: {:?}", cors);
log::info!("APP_ENV: {:?}", std::env::var("APP_ENV"));
log::info!("cors: {:?}", cors);

App::new()
.wrap(cors)
.app_data(web::Data::new(pool.clone()))
.service(fs::Files::new("/", "/track/server/static/client/").index_file("index.html"))
.service(
web::scope("/api")
.service(
web::resource("/weights")
.route(web::get().to(api::get_weights))
.route(web::post().to(api::post_weights)),
)
.service(
web::resource("/weights/{weight_id}")
.route(web::patch().to(api::patch_weights))
.route(web::delete().to(api::delete_weights)),
)
.service(
web::resource("/weights")
.route(web::get().to(api::get_weights))
.route(web::post().to(api::post_weights)),
),
)
.service(fs::Files::new("/", "/track/server/static/client/").index_file("index.html"))
})
.bind(format!("{}:{}", ip_address, port))?
.run()
Expand Down

0 comments on commit 3775adb

Please sign in to comment.