1
0
Fork 0
mirror of https://github.com/actix/actix-web.git synced 2024-10-21 17:33:59 +00:00

update guide

This commit is contained in:
Nikolay Kim 2018-03-29 10:01:07 -07:00
parent 7d6deab9fb
commit 32052c2750
3 changed files with 10 additions and 10 deletions

View file

@ -327,8 +327,8 @@ List of `FromParam` implementations can be found in
Actix provides functionality for type safe request path information extraction. Actix provides functionality for type safe request path information extraction.
It uses *serde* package as a deserialization library. It uses *serde* package as a deserialization library.
[HttpRequest::extract_path()](../actix_web/struct.HttpRequest.html#method.extract_path) [Path](../actix_web/struct.Path.html) extracts information, the destination type
extracts information, the destination type has to implement *serde's *`Deserialize` trait. has to implement *serde's *`Deserialize` trait.
```rust ```rust
# extern crate bytes; # extern crate bytes;
@ -342,20 +342,20 @@ struct Info {
username: String, username: String,
} }
fn index(mut req: HttpRequest) -> Result<String> { // extract path info using serde
let info: Info = req.extract_path()?; // <- extract path info using serde fn index(info: Path<Info>) -> Result<String> {
Ok(format!("Welcome {}!", info.username)) Ok(format!("Welcome {}!", info.username))
} }
fn main() { fn main() {
let app = Application::new() let app = Application::new()
.resource("/{username}/index.html", // <- define path parameters .resource("/{username}/index.html", // <- define path parameters
|r| r.method(Method::GET).f(index)); |r| r.method(Method::GET).with(index));
} }
``` ```
[HttpRequest::extract_query()](../actix_web/struct.HttpRequest.html#method.extract_query) [Query](../actix_web/struct.Query.html) provides similar functionality for
provides similar functionality for request query parameters. request query parameters.
## Generating resource URLs ## Generating resource URLs

View file

@ -130,7 +130,7 @@ impl Actor for Ws {
type Context = ws::WebsocketContext<Self>; type Context = ws::WebsocketContext<Self>;
} }
impl StreamHandler<ws::Message, ws::WsError> for Ws { impl StreamHandler<ws::Message, ws::ProtocolError> for Ws {
fn handle(&mut self, msg: ws::Message, ctx: &mut Self::Context) { fn handle(&mut self, msg: ws::Message, ctx: &mut Self::Context) {
match msg { match msg {

View file

@ -91,7 +91,7 @@ impl<T, S> Path<T, S> {
&self.req &self.req
} }
/// Deconstruct instance into a parts /// Deconstruct instance into parts
pub fn into(self) -> (T, HttpRequest<S>) { pub fn into(self) -> (T, HttpRequest<S>) {
(self.item, self.req) (self.item, self.req)
} }
@ -179,7 +179,7 @@ impl<T, S> Query<T, S> {
&self.req &self.req
} }
/// Deconstruct instance into a parts /// Deconstruct instance into parts
pub fn into(self) -> (T, HttpRequest<S>) { pub fn into(self) -> (T, HttpRequest<S>) {
(self.item, self.req) (self.item, self.req)
} }