Crate rapid_rs

Crate rapid_rs 

Source
Expand description

§rapid-rs

Zero-config, batteries-included web framework for Rust. FastAPI meets Spring Boot, powered by Axum.

§Quick Start

use rapid_rs::prelude::*;

#[tokio::main]
async fn main() {
    App::new()
        .auto_configure()
        .run()
        .await
        .unwrap();
}

§With Authentication

use rapid_rs::prelude::*;
use rapid_rs::auth::{AuthConfig, auth_routes};

#[tokio::main]
async fn main() {
    let auth_config = AuthConfig::from_env();
     
    App::new()
        .auto_configure()
        .mount(auth_routes(auth_config))
        .run()
        .await
        .unwrap();
}

§With Database Migrations

use rapid_rs::prelude::*;
use rapid_rs::database::{connect_and_migrate, MigrationConfig};

#[tokio::main]
async fn main() {
    let pool = connect_and_migrate(
        "postgres://localhost/myapp",
        MigrationConfig::default()
    ).await.unwrap();
     
    App::new()
        .auto_configure()
        .run()
        .await
        .unwrap();
}

Re-exports§

pub use app::App;
pub use error::ApiError;
pub use error::ApiResult;
pub use extractors::ValidatedJson;

Modules§

app
auth
Authentication and Authorization module for rapid-rs
config
database
Database utilities and helpers
error
extractors
prelude
Convenient re-exports for common types