From d24752d9bceea5548c96b94a70242bab7efd4048 Mon Sep 17 00:00:00 2001 From: Nikolay Kim Date: Thu, 29 Mar 2018 15:07:12 -0700 Subject: [PATCH] update example in readme --- README.md | 6 +++--- src/lib.rs | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 14a56cb9..869ee3a3 100644 --- a/README.md +++ b/README.md @@ -35,14 +35,14 @@ Actix web is a simple, pragmatic, extremely fast, web framework for Rust. extern crate actix_web; use actix_web::*; -fn index(req: HttpRequest) -> String { - format!("Hello {}!", &req.match_info()["name"]) +fn index(info: Path<(String, u32)>) -> String { + format!("Hello {}! id:{}", info.0, info.1) } fn main() { HttpServer::new( || Application::new() - .resource("/{name}", |r| r.f(index))) + .resource("/{name}/{id}/index.html", |r| r.with(index))) .bind("127.0.0.1:8080").unwrap() .run(); } diff --git a/src/lib.rs b/src/lib.rs index 6a1b27c4..4a29b1dc 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,18 +1,18 @@ //! Actix web is a small, pragmatic, extremely fast, web framework for Rust. //! //! ```rust -//! use actix_web::*; +//! use actix_web::{Application, HttpServer, Path}; //! # use std::thread; //! -//! fn index(req: HttpRequest) -> String { -//! format!("Hello {}!", &req.match_info()["name"]) +//! fn index(info: Path<(String, u32)>) -> String { +//! format!("Hello {}! id:{}", info.0, info.1) //! } //! //! fn main() { //! # thread::spawn(|| { //! HttpServer::new( //! || Application::new() -//! .resource("/{name}", |r| r.f(index))) +//! .resource("/{name}/{id}/index.html", |r| r.with(index))) //! .bind("127.0.0.1:8080").unwrap() //! .run(); //! # });