Rupring v0.2.0
https://crates.io/crates/rupring
https://github.com/myyrakle/rupring/releases/tag/v0.2.0
๋ง๋ค์๋ค.
๋ด ์ทจํฅ๋๋ก ๊พธ๋ฉฐ๋ณธ ์๋ฒ ํ๋ ์์ํฌ๋ค.
tokio/hyper ์คํ์ผ๋ก ์ง์ ์์๊ณ , Nest.js ์คํ์ผ์ ๊ตฌ์ฑ์ ์ต๋ํ ๋ฐ๋ฅด๊ณ ์ ํ๋ค.
์ฌ์ฉ๋ฒ์ ๊ฐ๋จํ๋ค.
๋ํ๋์ ์ถ๊ฐํ๊ณ

์ด๋ฐ ํํ๋ก ๋ชจ๋/์ปจํธ๋กค๋ฌ/route ๊ตฌ์กฐ๋ฅผ ์ง๊ณ

#[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 {
status: 200,
body: "Hello, World!".to_string(),
headers: Default::default(),
}
}
#[rupring::Get(path = /echo)]
pub fn echo(request: rupring::Request) -> rupring::Response {
rupring::Response {
status: 200,
body: request.body,
headers: Default::default(),
}
}
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
use std::net::SocketAddr;
let addr = SocketAddr::from(([127, 0, 0, 1], 3000));
let module = RootModule {};
rupring::boot::run_server(addr, module).await?;
Ok(())
}
์คํํ๋ฉด ๋๋ค.

๊ทธ๋ผ ์ ๋ฐ ๊ฒ์ด๋ค.


๊ทธ๋ฐ๋๋ก ๋์์ ํ์ง๋ง ์์ง ๋ถ์กฑํ๊ฒ ๋๋ฌด ๋ง๋ค.
์ง๋ ฌํ/์ญ์ง๋ ฌํ๋ ์๊ณ , ์์ง DI๋ ์๋ค. ๋ฏธ๋ค์จ์ด๋ ์๊ณ , ์๋ ๋ฌธ์ํ๋ ์๋ค.
ํ์ ๋์ถฉ ์งฐ์ผ๋ ์ด์ ์ฒ์ฒํ ์ถ๊ฐํด๋ณด๋ ค ํ๋ค.