RustFul a new web framework for Rust

Hi everyone, I'm working on a new web framework for the Rust programming language focused on building web APIs, I hope to finish and launch the first version on GitHub in February.

https://github.com/rustful-rs

examples :

#[tokio::main]
async fn main() {
    let app = RustFul::new();

    // GET /
    app.get("/", |_ctx| async move {
        Ok(
            Response::new("Hello, World 👋!".into())
        )
    }).await;

    app.run(":3000").await
}

Group is used for Routes with common prefix to define a new sub-router

async fn index(_ctx: Context) -> rustful::Result<Response<Body>> {
    // my logic
    Ok(Response::new(INDEX.into()))
}

#[tokio::main]
async fn main() {
    let app = RustFul::new();

    // GET /
    app.get("/", |_ctx| async move {
        // my logic
        let response = Response::builder()
                               .status(StatusCode::NOT_FOUND)
                                .body(NOTFOUND.into())
                                .unwrap(); 

        Ok(response)
    }).await;

    let api = app.group("api");

    let user = api.group("user");

    // GET /api/user
    user.get("/", index).await;

    let post = api.group("post");

    // GET /api/post
    post.get("/", index).await;

    // GET /api/post/all
    post.get("/all", |_ctx| async move {
        Ok(Response::new("GET /api/post/all".into()))
    }).await;

    app.run(":3000 ").await
}

thank you for your support

2 Likes

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.