rupring

Crates.iorupring
lib.rsrupring
version0.7.1
sourcesrc
created_at2023-10-10 15:56:21.652799
updated_at2024-02-02 18:55:59.657964
descriptionRupring
homepagehttps://github.com/myyrakle/rupring/blob/master/README.md
repositoryhttps://github.com/myyrakle/rupring
max_upload_size
id999257
size1,952,993
myyrakle (myyrakle)

documentation

https://docs.rs/rupring/latest/rupring

README

rupring

GitHub license

spring on rust

Get Started

There is only one dependency.

cargo add rupring

And you can write your server like this:

#[derive(Debug, Clone, Copy)]
#[rupring::Module(controllers=[HomeController{}], modules=[])]
pub struct RootModule {}

#[derive(Debug, Clone)]
#[rupring::Controller(prefix=/, routes=[hello, echo])]
pub struct HomeController {}

#[rupring::Get(path = /)]
pub fn hello(_request: rupring::Request) -> rupring::Response {
    rupring::Response::new().text("Hello, World!".to_string())
}

#[rupring::Get(path = /echo)]
pub fn echo(request: rupring::Request) -> rupring::Response {
    rupring::Response::new().text(request.body)
}

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
    let app = rupring::RupringFactory::create(RootModule {});

    app.listen(3000).await?;

    Ok(())
}

And if you run the program, it will work fine.
Alt text

More Details

Please refer to the documentation for more details.

Commit count: 114

cargo fmt