13 releases (8 breaking)

0.11.0 Nov 30, 2024
0.7.2 Aug 20, 2024
0.7.1 Feb 2, 2024
0.6.0 Dec 27, 2023
0.1.0 Oct 10, 2023

#1068 in Procedural macros

Download history 317/week @ 2024-08-26 47/week @ 2024-09-16 17/week @ 2024-09-23 34/week @ 2024-09-30 1/week @ 2024-10-07 1/week @ 2024-11-18 110/week @ 2024-11-25 56/week @ 2024-12-02 16/week @ 2024-12-09

183 downloads per month
Used in rupring

MIT license

50KB
1K SLoC

rupring

GitHub license

Spring Comes to Rust

Get Started

required dependency list

rupring = "0.9.1"
serde = { version="1.0.193", features=["derive"] }

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)
}

fn main() {
    rupring::run(RootModule {})
}

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

More Details

Please refer to the documentation for more details.

Dependencies

~220–660KB
~16K SLoC