rwf 0.1.7

Framework for building web applications in the Rust programming language
Documentation

Rwf is a comprehensive framework for building web applications in Rust. Written using the classic MVC pattern (model-view-controller), Rwf comes standard with everything you need to easily build fast and secure web apps.

Getting started

Rwf is a Rust library built on top of Tokio, and can be added to any binary or library Rust project:

cargo add rwf
cargo add tokio@1 --features full

Rwf has many types and traits that make it ergonomic. You can include them all with just one import:

use rwf::prelude::*;

While not required, this makes things simpler.

Controllers

Rwf is an MVC framework, so Controllers are fundamental to serving HTTP requests. Defining controllers requires imlementing the [controller::Controller] trait for a struct:

#[derive(Default)]
struct Index;

#[async_trait]
impl Controller for Index {
async fn handle(&self, request: &Request) -> Result<Response, Error> {
Ok(Response::new().html("<h1>Hello from Rwf!</h1>"))
}
}

Most Rwf traits are asynchronous and use the async_trait crate to make it user-friendly.

HTTP server

Launching the Rwf HTTP server requires mapping routes to controllers, and can be done at application startup:

use rwf::http::Server;

#[tokio::main]
async fn main() {
Server::new(vec![
route!("/" => IndexController),
])
.launch("0.0.0.0:8000")
.await
.unwrap();
}

Documentation

Rwf docs are primarily located here. While maintaining two sets of documentation can be challenging, we'll make every effort to maintain both versions. Most public methods have some documentation and examples.