1
0
mirror of https://github.com/actix/examples synced 2025-06-26 17:17:42 +02:00

group imports

This commit is contained in:
Rob Ede
2022-07-09 21:08:11 +01:00
parent 4b801ba222
commit a64e21ee6e
23 changed files with 66 additions and 50 deletions

View File

@ -51,10 +51,11 @@ mod errors {
}
mod db {
use crate::{errors::MyError, models::User};
use deadpool_postgres::Client;
use tokio_pg_mapper::FromTokioPostgresRow;
use crate::{errors::MyError, models::User};
pub async fn add_user(client: &Client, user_info: User) -> Result<User, MyError> {
let _stmt = include_str!("../sql/add_user.sql");
let _stmt = _stmt.replace("$table_fields", &User::sql_table_fields());
@ -80,10 +81,11 @@ mod db {
}
mod handlers {
use crate::{db, errors::MyError, models::User};
use actix_web::{web, Error, HttpResponse};
use deadpool_postgres::{Client, Pool};
use crate::{db, errors::MyError, models::User};
pub async fn add_user(
user: web::Json<User>,
db_pool: web::Data<Pool>,
@ -98,13 +100,14 @@ mod handlers {
}
}
use crate::config::ExampleConfig;
use ::config::Config;
use actix_web::{web, App, HttpServer};
use dotenv::dotenv;
use handlers::add_user;
use tokio_postgres::NoTls;
use crate::config::ExampleConfig;
#[actix_web::main]
async fn main() -> std::io::Result<()> {
dotenv().ok();