use actix_web::{head, web, HttpResponse, Responder, Result}; use bank::account::AccountError; use serde::Serialize; use crate::handlers::error::HttpAccountError; use crate::AppState; #[derive(Serialize)] struct AccountCreated { nr: String, } #[head("/{nr}")] pub async fn route(info: web::Path, data: web::Data) -> Result { let nr = info.into_inner(); info!("checking account {}...", nr); let bank = data.bank.read().unwrap(); match bank.accounts.get(&nr) { None => Err(HttpAccountError(AccountError::NotFound).into()), Some(account) => { let account = account.read().unwrap(); if account.is_active { Ok(HttpResponse::Ok().finish()) } else { Err(HttpAccountError(AccountError::Inactive).into()) } } } }