Closed Cyrelb closed 3 years ago
Hi, I have issue to integrate the library. My code is the following:
Main:
fn main() { HttpServer::new(move || { App::new() .data(AppState { pool: pool.clone(), log: log.clone(), }) .wrap(middleware::Logger::default()) .route("/", web::get().to(status)) .route("/test{_:/?}", web::get().to(test)) }) .bind(format!("{}:{}", config.server.host, config.server.port))? .run() .await }
Handler:
pub async fn status() -> Result<impl Responder, AppError> { Ok(web::HttpResponse::Ok().json(Status { status: "Up".to_string(), })) } pub async fn test(state: web::Data<AppState>) -> Result<impl Responder, AppError> { let sublog = state.log.new(o!("handler" => "test")); let client: Client = get_client(state.pool.clone(), sublog.clone()).await?; let result = db::get_test(&client).await; result .map(|test| HttpResponse::Ok().json(test)) .map_err(log_error(sublog)) }
@Cyrelb What kind of issue do you have? Is it issue about actix-swagger? Not about actix-web?
actix-swagger
actix-web
Hi, I have issue to integrate the library. My code is the following:
Main:
Handler: