1
0
mirror of https://github.com/actix/actix-extras.git synced 2024-11-24 07:53:00 +01:00

update tests

This commit is contained in:
Nikolay Kim 2018-04-06 09:45:10 -07:00
parent 2dafd9c681
commit 691457fbfe
5 changed files with 10 additions and 10 deletions

View File

@ -33,14 +33,14 @@ Actix web is a simple, pragmatic, extremely fast, web framework for Rust.
```rust ```rust
extern crate actix_web; extern crate actix_web;
use actix_web::{App, HttpServer, Path}; use actix_web::{server, App, Path};
fn index(info: Path<(String, u32)>) -> String { fn index(info: Path<(String, u32)>) -> String {
format!("Hello {}! id:{}", info.0, info.1) format!("Hello {}! id:{}", info.0, info.1)
} }
fn main() { fn main() {
HttpServer::new( server::new(
|| App::new() || App::new()
.resource("/{name}/{id}/index.html", |r| r.with(index))) .resource("/{name}/{id}/index.html", |r| r.with(index)))
.bind("127.0.0.1:8080").unwrap() .bind("127.0.0.1:8080").unwrap()

View File

@ -439,7 +439,7 @@ impl<S> App<S> where S: 'static {
/// ```rust /// ```rust
/// # use std::thread; /// # use std::thread;
/// # extern crate actix_web; /// # extern crate actix_web;
/// use actix_web::*; /// use actix_web::{server, App, HttpResponse};
/// ///
/// struct State1; /// struct State1;
/// ///
@ -447,7 +447,7 @@ impl<S> App<S> where S: 'static {
/// ///
/// fn main() { /// fn main() {
/// # thread::spawn(|| { /// # thread::spawn(|| {
/// HttpServer::new(|| { vec![ /// server::new(|| { vec![
/// App::with_state(State1) /// App::with_state(State1)
/// .prefix("/app1") /// .prefix("/app1")
/// .resource("/", |r| r.f(|r| HttpResponse::Ok())) /// .resource("/", |r| r.f(|r| HttpResponse::Ok()))

View File

@ -1,7 +1,7 @@
//! 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::{App, HttpServer, Path}; //! use actix_web::{server, App, Path};
//! # use std::thread; //! # use std::thread;
//! //!
//! fn index(info: Path<(String, u32)>) -> String { //! fn index(info: Path<(String, u32)>) -> String {
@ -10,7 +10,7 @@
//! //!
//! fn main() { //! fn main() {
//! # thread::spawn(|| { //! # thread::spawn(|| {
//! HttpServer::new( //! server::new(
//! || App::new() //! || App::new()
//! .resource("/{name}/{id}/index.html", |r| r.with(index))) //! .resource("/{name}/{id}/index.html", |r| r.with(index)))
//! .bind("127.0.0.1:8080").unwrap() //! .bind("127.0.0.1:8080").unwrap()

View File

@ -262,12 +262,12 @@ impl<H: IntoHttpHandler> HttpServer<H>
/// ```rust /// ```rust
/// extern crate actix; /// extern crate actix;
/// extern crate actix_web; /// extern crate actix_web;
/// use actix_web::*; /// use actix_web::{server, App, HttpResponse};
/// ///
/// fn main() { /// fn main() {
/// let sys = actix::System::new("example"); // <- create Actix system /// let sys = actix::System::new("example"); // <- create Actix system
/// ///
/// HttpServer::new( /// server::new(
/// || App::new() /// || App::new()
/// .resource("/", |r| r.h(|_| HttpResponse::Ok()))) /// .resource("/", |r| r.h(|_| HttpResponse::Ok())))
/// .bind("127.0.0.1:0").expect("Can not bind to 127.0.0.1:0") /// .bind("127.0.0.1:0").expect("Can not bind to 127.0.0.1:0")

View File

@ -63,7 +63,7 @@ fn test_start() {
thread::spawn(move || { thread::spawn(move || {
let sys = System::new("test"); let sys = System::new("test");
let srv = HttpServer::new( let srv = server::new(
|| vec![App::new() || vec![App::new()
.resource( .resource(
"/", |r| r.method(http::Method::GET) "/", |r| r.method(http::Method::GET)
@ -108,7 +108,7 @@ fn test_shutdown() {
thread::spawn(move || { thread::spawn(move || {
let sys = System::new("test"); let sys = System::new("test");
let srv = HttpServer::new( let srv = server::new(
|| vec![App::new() || vec![App::new()
.resource( .resource(
"/", |r| r.method(http::Method::GET).f(|_| HttpResponse::Ok()))]); "/", |r| r.method(http::Method::GET).f(|_| HttpResponse::Ok()))]);