Tower-web 0.3.1/2 釋出,型別完善和修復更新
Tower-web:Rust的快速,無樣板,Web框架
0.3.2更新
0.3.1 更新
-
修復panic在內容型別未提供時 (#123).
-
所有數字型別實現
Extract
(#131). -
忽略其他derives的屬性 (#130).
-
禁用日誌記錄時避免clone(#126).
-
新增非阻塞
serve
方法來執行伺服器 (#76).
Tower-web介紹:
#[macro_use] externcrate tower_web; externcrate tokio; 使用 tower_web :: ServiceBuilder; 使用 tokio :: prelude :: * ; ///此型別將作為資源的Web服務的一部分。 #[derive(Clone,Debug)] structHelloWorld ; ///這將是JSON響應 #[匯出(響應)] structHelloResponse { 訊息:&' staticstr, } impl_web!{ implHelloWorld { #[get(“/”)] #[content_type(“json”)] fnhello_world(&self) - > Result <HelloResponse,()> { Ok(HelloResponse { 訊息:“你好世界”, }) } } } pubfnmain(){ let addr =“127.0.0.1:8080”。解析()。期望(“無效地址”); 呼叫println!(“聽取http:// {}”,addr); ServiceBuilder :: new() 。資源(HelloWorld) 。執行(& addr) 。unwrap(); }
Tower-web 基於 Tokio (Rust的併發框架與平臺)和Hyper (Rust的HTTP的server框架)。
Tower-web 是 Tokio 生態系統的一部分。
[Tokio英文站點] (https://tokio.rs/ )
[Tokio中文站點] (https://tokio-zh.github.io/ )
[Tokio社群] (https://tokio-zh.github.io/community/ )