mirror of
https://github.com/actix/actix-web.git
synced 2024-11-26 11:31:09 +00:00
update example in readme
This commit is contained in:
parent
92fe2e96de
commit
d24752d9bc
2 changed files with 7 additions and 7 deletions
|
@ -35,14 +35,14 @@ Actix web is a simple, pragmatic, extremely fast, web framework for Rust.
|
||||||
extern crate actix_web;
|
extern crate actix_web;
|
||||||
use actix_web::*;
|
use actix_web::*;
|
||||||
|
|
||||||
fn index(req: HttpRequest) -> String {
|
fn index(info: Path<(String, u32)>) -> String {
|
||||||
format!("Hello {}!", &req.match_info()["name"])
|
format!("Hello {}! id:{}", info.0, info.1)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
HttpServer::new(
|
HttpServer::new(
|
||||||
|| Application::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()
|
.bind("127.0.0.1:8080").unwrap()
|
||||||
.run();
|
.run();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,18 +1,18 @@
|
||||||
//! Actix web is a small, pragmatic, extremely fast, web framework for Rust.
|
//! Actix web is a small, pragmatic, extremely fast, web framework for Rust.
|
||||||
//!
|
//!
|
||||||
//! ```rust
|
//! ```rust
|
||||||
//! use actix_web::*;
|
//! use actix_web::{Application, HttpServer, Path};
|
||||||
//! # use std::thread;
|
//! # use std::thread;
|
||||||
//!
|
//!
|
||||||
//! fn index(req: HttpRequest) -> String {
|
//! fn index(info: Path<(String, u32)>) -> String {
|
||||||
//! format!("Hello {}!", &req.match_info()["name"])
|
//! format!("Hello {}! id:{}", info.0, info.1)
|
||||||
//! }
|
//! }
|
||||||
//!
|
//!
|
||||||
//! fn main() {
|
//! fn main() {
|
||||||
//! # thread::spawn(|| {
|
//! # thread::spawn(|| {
|
||||||
//! HttpServer::new(
|
//! HttpServer::new(
|
||||||
//! || Application::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()
|
//! .bind("127.0.0.1:8080").unwrap()
|
||||||
//! .run();
|
//! .run();
|
||||||
//! # });
|
//! # });
|
||||||
|
|
Loading…
Reference in a new issue