Skip to content

Commit

Permalink
pass trait object to to rust webserver handler
Browse files Browse the repository at this point in the history
  • Loading branch information
mxfactorial committed Oct 7, 2023
1 parent 3d9a8c3 commit ca0fa6c
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions services/rule/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ use axum::{
routing::{get, post},
Router,
};
use pg::{ConnectionPool, DB};
use pg::{DynConnPool, DB};
use rule::{create_response, expected_values, label_approved_transaction_items};
use std::{env, net::ToSocketAddrs};
use std::{env, net::ToSocketAddrs, sync::Arc};
use tokio::signal;
use types::approval::{Approval, Approvals};
use types::{
Expand Down Expand Up @@ -173,7 +173,7 @@ async fn apply_approval_rules<C: AccountStore + RuleInstanceStore>(
}

async fn apply_rules(
State(pool): State<ConnectionPool>,
State(pool): State<DynConnPool>,
transaction_items: Json<TransactionItems>,
) -> Result<axum::Json<IntraTransaction>, StatusCode> {
if !expected_values(&transaction_items) {
Expand Down Expand Up @@ -233,7 +233,7 @@ async fn main() {

let conn_uri = DB::create_conn_uri_from_env_vars();

let pool = DB::new_pool(&conn_uri).await;
let pool = Arc::new(DB::new_pool(&conn_uri).await) as DynConnPool;

let service_route = Router::new().route("/", post(apply_rules)).with_state(pool);

Expand Down

0 comments on commit ca0fa6c

Please sign in to comment.