diff --git a/content/_index.cn.md b/content/_index.cn.md index 2a3865f..b10170b 100644 --- a/content/_index.cn.md +++ b/content/_index.cn.md @@ -1,3 +1,3 @@ --- -title: Actix中文社区 +title: Actix中文 --- diff --git a/layouts/index.html b/layouts/index.html index 10ea459..7ee8f05 100644 --- a/layouts/index.html +++ b/layouts/index.html @@ -1,154 +1,298 @@ {{ partial "header" . }} -
rust's powerful actor system and most fun web framework
-Forget about stringly typed objects, from request to response, everything has types.
- -Actix provides a lot of features out of box. WebSockets, HTTP/2, pipelining etc.
- -Easily create your own libraries that any Actix application can use.
- -Actix is blazingly fast. Check yourself.
+Rust的actor系统和有趣的web框架
忘记关于字符串类型的对象,从请求到响应,一切都有类型,异步。
+ +Actix提供了丰富的特性开箱即用。WebSockets,HTTP/2,流,管道,SSL,异步HTTTP客户端等一应俱全.
+ +轻松创建任何基于Actix应用的自己的特色库。
+ +Actix 具有顶级的速度. Check yourself.
++ Actix中的Handler函数可以返回实现该Respondert rait的各种对象。这使得从API返回一致的响应变得轻而易举。 +
+ {{ highlight `#[derive(Serialize)] + struct Measurement { + temperature: f32, + } + + fn hello_world() -> impl Responder { + "Hello World!" + } + + fn current_temperature(_req: HttpRequest) -> impl Responder { + Json(Measurement { temperature: 42.3 }) + }` "rust" "" }} ++ Actix提供了一个强大的提取器系统,可以从传入的HTTP请求中提取数据并将其传递给您的视图函数。这不仅可以创建方便的API, + 而且还意味着您的视图函数可以是同步代码,并且仍然可以受益于异步IO处理。 +
+ {{ highlight `#[derive(Deserialize)] + struct Event { + timestamp: f64, + kind: String, + tags: Vec+ 处理multipart/ urlencoded表单数据很容易。只需定义一个可以反序列化的结构,actix就可以处理剩下的部分。 +
+ {{ highlight `#[derive(Deserialize)] + struct Register { + username: String, + country: String, + } + + fn register(data: Form+ 一个actix应用程序带有一个URL路由系统,可以让你在URL上匹配并调用单个处理程序。为了获得额外的灵活性,可以使用域。 +
+ {{ highlight `fn index(req: HttpRequest) -> impl Responder { + "Hello from the index page" + } + + fn hello(path: Path
- Handler functions in actix can return a wide range of objects that
- implement the Responder
trait. This makes it a breeze
- to return consistent responses from your APIs.
-
rust's powerful actor system and most fun web framework
+Forget about stringly typed objects, from request to response, everything has types.
+ +Actix provides a lot of features out of box. WebSockets, HTTP/2, pipelining etc.
+ +Easily create your own libraries that any Actix application can use.
+ +Actix is blazingly fast. Check yourself.
+- Actix comes with a powerful extractor system that extracts data - from the incoming HTTP request and passes it to your view functions. - Not only does this make for a convenient API but it also means that - your view functions can be synchronous code and still benefit - from asynchronous IO handling. -
- {{ highlight `#[derive(Deserialize)] -struct Event { - timestamp: f64, - kind: String, - tags: Vec- Handling multipart/urlencoded form data is easy. Just define - a structure that can be deserialized and actix will handle - the rest. -
- {{ highlight `#[derive(Deserialize)] -struct Register { - username: String, - country: String, -} + fn greet(req: HttpRequest) -> impl Responder { + let to = req.match_info().get("name").unwrap_or("World"); + format!("Hello {}!", to) + } -fn register(data: Form- An actix app comes with a URL routing system that lets you match on - URLs and invoke individual handlers. For extra flexibility, scopes - can be used. -
- {{ highlight `fn index(req: HttpRequest) -> impl Responder { - "Hello from the index page" -} - -fn hello(path: Path
+ Handler functions in actix can return a wide range of objects that
+ implement the Responder
trait. This makes it a breeze
+ to return consistent responses from your APIs.
+
+ Actix comes with a powerful extractor system that extracts data + from the incoming HTTP request and passes it to your view functions. + Not only does this make for a convenient API but it also means that + your view functions can be synchronous code and still benefit + from asynchronous IO handling. +
+ {{ highlight `#[derive(Deserialize)] + struct Event { + timestamp: f64, + kind: String, + tags: Vec+ Handling multipart/urlencoded form data is easy. Just define + a structure that can be deserialized and actix will handle + the rest. +
+ {{ highlight `#[derive(Deserialize)] + struct Register { + username: String, + country: String, + } + + fn register(data: Form+ An actix app comes with a URL routing system that lets you match on + URLs and invoke individual handlers. For extra flexibility, scopes + can be used. +
+ {{ highlight `fn index(req: HttpRequest) -> impl Responder { + "Hello from the index page" + } + + fn hello(path: Path