mirror of
https://github.com/actix/actix-website
synced 2025-06-27 07:29:02 +02:00
v3 (#188)
This commit is contained in:
@ -4,9 +4,8 @@ version = "1.0.0"
|
||||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
actix-web = "2.0"
|
||||
actix-rt = "1.0"
|
||||
actix-service = "1.0"
|
||||
actix-session = "0.3"
|
||||
futures = "0.3.1"
|
||||
env_logger = "0.6"
|
||||
actix-web = "3"
|
||||
actix-service = "1"
|
||||
actix-session = "0.4"
|
||||
futures = "0.3"
|
||||
env_logger = "0.7"
|
||||
|
@ -1,7 +1,7 @@
|
||||
// <default-headers>
|
||||
use actix_web::{http, middleware, HttpResponse};
|
||||
|
||||
#[actix_rt::main]
|
||||
#[actix_web::main]
|
||||
async fn main() -> std::io::Result<()> {
|
||||
use actix_web::{web, App, HttpServer};
|
||||
|
||||
@ -17,7 +17,7 @@ async fn main() -> std::io::Result<()> {
|
||||
),
|
||||
)
|
||||
})
|
||||
.bind("127.0.0.1:8088")?
|
||||
.bind("127.0.0.1:8080")?
|
||||
.run()
|
||||
.await
|
||||
}
|
||||
|
@ -1,3 +1,5 @@
|
||||
#![allow(dead_code)]
|
||||
|
||||
// <error-handler>
|
||||
use actix_web::middleware::errhandlers::{ErrorHandlerResponse, ErrorHandlers};
|
||||
use actix_web::{dev, http, HttpResponse, Result};
|
||||
@ -10,7 +12,7 @@ fn render_500<B>(mut res: dev::ServiceResponse<B>) -> Result<ErrorHandlerRespons
|
||||
Ok(ErrorHandlerResponse::Response(res))
|
||||
}
|
||||
|
||||
#[actix_rt::main]
|
||||
#[actix_web::main]
|
||||
async fn main() -> std::io::Result<()> {
|
||||
use actix_web::{web, App, HttpServer};
|
||||
|
||||
@ -26,7 +28,7 @@ async fn main() -> std::io::Result<()> {
|
||||
.route(web::head().to(|| HttpResponse::MethodNotAllowed())),
|
||||
)
|
||||
})
|
||||
.bind("127.0.0.1:8088")?
|
||||
.bind("127.0.0.1:8080")?
|
||||
.run()
|
||||
.await
|
||||
}
|
||||
|
@ -2,7 +2,7 @@
|
||||
use actix_web::middleware::Logger;
|
||||
use env_logger::Env;
|
||||
|
||||
#[actix_rt::main]
|
||||
#[actix_web::main]
|
||||
async fn main() -> std::io::Result<()> {
|
||||
use actix_web::{App, HttpServer};
|
||||
|
||||
@ -13,7 +13,7 @@ async fn main() -> std::io::Result<()> {
|
||||
.wrap(Logger::default())
|
||||
.wrap(Logger::new("%a %{User-Agent}i"))
|
||||
})
|
||||
.bind("127.0.0.1:8088")?
|
||||
.bind("127.0.0.1:8080")?
|
||||
.run()
|
||||
.await
|
||||
}
|
||||
|
@ -74,7 +74,7 @@ where
|
||||
}
|
||||
// </simple>
|
||||
|
||||
#[actix_rt::main]
|
||||
#[actix_web::main]
|
||||
async fn main() -> std::io::Result<()> {
|
||||
use actix_web::{web, App, HttpServer};
|
||||
|
||||
@ -86,7 +86,7 @@ async fn main() -> std::io::Result<()> {
|
||||
}),
|
||||
)
|
||||
})
|
||||
.bind("127.0.0.1:8088")?
|
||||
.bind("127.0.0.1:8080")?
|
||||
.run()
|
||||
.await
|
||||
}
|
||||
|
@ -1,3 +1,5 @@
|
||||
#![allow(dead_code)]
|
||||
|
||||
// <user-session>
|
||||
use actix_session::{CookieSession, Session};
|
||||
use actix_web::{web, App, Error, HttpResponse, HttpServer};
|
||||
@ -16,7 +18,7 @@ async fn index(session: Session) -> Result<HttpResponse, Error> {
|
||||
)))
|
||||
}
|
||||
|
||||
#[actix_rt::main]
|
||||
#[actix_web::main]
|
||||
async fn main() -> std::io::Result<()> {
|
||||
HttpServer::new(|| {
|
||||
App::new()
|
||||
@ -26,7 +28,7 @@ async fn main() -> std::io::Result<()> {
|
||||
)
|
||||
.service(web::resource("/").to(index))
|
||||
})
|
||||
.bind("127.0.0.1:8088")?
|
||||
.bind("127.0.0.1:8080")?
|
||||
.run()
|
||||
.await
|
||||
}
|
||||
|
@ -1,9 +1,11 @@
|
||||
#![allow(dead_code, unused_variables)]
|
||||
|
||||
// <wrap-fn>
|
||||
use actix_service::Service;
|
||||
use actix_web::{web, App};
|
||||
use futures::future::FutureExt;
|
||||
|
||||
#[actix_rt::main]
|
||||
#[actix_web::main]
|
||||
async fn main() {
|
||||
let app = App::new()
|
||||
.wrap_fn(|req, srv| {
|
||||
|
Reference in New Issue
Block a user