bloom-web 0.1.4

A lightweight backend framework combining Actix-Web, SQLx, and declarative macros for rapid API development
use bloom_web::prelude::*;

#[derive(Entity, Debug, Clone, Serialize, Deserialize, FromRow)]
#[table("bloom_users")]
#[allow(dead_code)]
pub struct BloomUser {
    #[id]
    pub id: i32,
    pub name: String,
    pub email: String,
}

#[repository(BloomUser)]
pub struct UserRepository;

#[get_mapping("/users/{id}")]
pub async fn get_bloom_user_by_id(path: web::Path<i64>, pool: web::Data<MySqlPool>) -> impl actix_web::Responder {
    match UserRepository::find_by_id::<BloomUser>(pool.get_ref(), path.into_inner()).await {
        Ok(Some(user)) => HttpResponse::Ok().json(user),
        Ok(None) => HttpResponse::NotFound().finish(),
        Err(_) => HttpResponse::InternalServerError().finish(),
    }
}

fn main() {
    println!("Bloom Web Framework test with user's code compiled successfully!");
    println!("All dependencies are properly accessible including web::Path and actix_web::Responder!");
}