1
0
mirror of https://github.com/actix/actix-extras.git synced 2025-06-25 18:09:22 +02:00

do not re-export HttpServer from server module

This commit is contained in:
Nikolay Kim
2018-04-06 08:40:11 -07:00
parent 12586db15c
commit 2dafd9c681
21 changed files with 47 additions and 47 deletions

View File

@ -179,7 +179,7 @@ session data.
```rust
# extern crate actix;
# extern crate actix_web;
use actix_web::*;
use actix_web::{server, App, HttpRequest, Result};
use actix_web::middleware::{RequestSession, SessionStorage, CookieSessionBackend};
fn index(mut req: HttpRequest) -> Result<&'static str> {
@ -196,7 +196,7 @@ fn index(mut req: HttpRequest) -> Result<&'static str> {
fn main() {
# let sys = actix::System::new("basic-example");
HttpServer::new(
server::new(
|| App::new()
.middleware(SessionStorage::new( // <- create session middleware
CookieSessionBackend::build(&[0; 32]) // <- create cookie session backend

View File

@ -69,7 +69,7 @@ The full source of src/main.rs is listed below:
```rust
# use std::thread;
extern crate actix_web;
use actix_web::{App, HttpRequest, HttpResponse, HttpServer};
use actix_web::{server, App, HttpRequest, HttpResponse};
fn index(req: HttpRequest) -> &'static str {
"Hello world!"
@ -80,7 +80,7 @@ fn main() {
# // If copying this example in show-all mode, make sure you skip the thread spawn
# // call.
# thread::spawn(|| {
HttpServer::new(
server::HttpServer::new(
|| App::new()
.resource("/", |r| r.f(index)))
.bind("127.0.0.1:8088").expect("Can not bind to 127.0.0.1:8088")

View File

@ -45,10 +45,10 @@ Multiple applications can be served with one server:
# extern crate tokio_core;
# use tokio_core::net::TcpStream;
# use std::net::SocketAddr;
use actix_web::{App, HttpResponse, HttpServer};
use actix_web::{server, App, HttpResponse};
fn main() {
HttpServer::new(|| vec![
server::new(|| vec![
App::new()
.prefix("/app1")
.resource("/", |r| r.f(|r| HttpResponse::Ok())),

View File

@ -1,6 +1,6 @@
# Server
The [**HttpServer**](../actix_web/struct.HttpServer.html) type is responsible for
The [**HttpServer**](../actix_web/server/struct.HttpServer.html) type is responsible for
serving http requests.
`HttpServer` accepts an application factory as a parameter, and the
@ -18,13 +18,12 @@ To start the http server, one of the start methods.
```rust
# extern crate actix;
# extern crate actix_web;
use actix::*;
use actix_web::{server, App, HttpResponse};
use actix_web::{server::HttpServer, App, HttpResponse};
fn main() {
let sys = actix::System::new("guide");
server::new(
HttpServer::new(
|| App::new()
.resource("/", |r| r.f(|_| HttpResponse::Ok())))
.bind("127.0.0.1:59080").unwrap()
@ -54,8 +53,7 @@ address of the started http server. It accepts several messages:
# use futures::Future;
use std::thread;
use std::sync::mpsc;
use actix::*;
use actix_web::{server, App, HttpResponse, HttpServer};
use actix_web::{server, App, HttpResponse};
fn main() {
let (tx, rx) = mpsc::channel();
@ -87,7 +85,7 @@ can be overridden with the `HttpServer::threads()` method.
```rust
# extern crate actix_web;
# extern crate tokio_core;
use actix_web::{App, HttpServer, HttpResponse};
use actix_web::{App, HttpResponse, server::HttpServer};
fn main() {
HttpServer::new(
@ -123,7 +121,7 @@ fn main() {
builder.set_private_key_file("key.pem", SslFiletype::PEM).unwrap();
builder.set_certificate_chain_file("cert.pem").unwrap();
HttpServer::new(
server::new(
|| App::new()
.resource("/index.html", |r| r.f(index)))
.bind("127.0.0.1:8080").unwrap()

View File

@ -130,7 +130,7 @@ Let's create a response for a custom type that serializes to an `application/jso
extern crate serde;
extern crate serde_json;
#[macro_use] extern crate serde_derive;
use actix_web::{App, HttpServer, HttpRequest, HttpResponse, Error, Responder, http};
use actix_web::{server, App, HttpRequest, HttpResponse, Error, Responder, http};
#[derive(Serialize)]
struct MyObj {
@ -160,7 +160,7 @@ fn index(req: HttpRequest) -> MyObj {
fn main() {
let sys = actix::System::new("example");
HttpServer::new(
server::new(
|| App::new()
.resource("/", |r| r.method(http::Method::GET).f(index)))
.bind("127.0.0.1:8088").unwrap()