1
0
mirror of https://github.com/fafhrd91/actix-web synced 2025-06-25 06:39:22 +02:00

reexpost extractors in web module

This commit is contained in:
Nikolay Kim
2019-03-07 11:43:46 -08:00
parent 22708e78a9
commit ceb6d45bf2
6 changed files with 41 additions and 42 deletions

View File

@ -3,10 +3,10 @@ use futures::IntoFuture;
use actix_web::macros::get;
use actix_web::{middleware, web, App, Error, HttpRequest, HttpResponse, HttpServer};
#[get("/resource1/index.html")]
fn index(req: HttpRequest) -> &'static str {
#[get("/resource1/{name}/index.html")]
fn index(req: HttpRequest, name: web::Path<String>) -> String {
println!("REQ: {:?}", req);
"Hello world!\r\n"
format!("Hello: {}!\r\n", name)
}
fn index_async(req: HttpRequest) -> impl IntoFuture<Item = &'static str, Error = Error> {
@ -20,14 +20,14 @@ fn no_params() -> &'static str {
}
fn main() -> std::io::Result<()> {
::std::env::set_var("RUST_LOG", "actix_server=info,actix_web2=info");
std::env::set_var("RUST_LOG", "actix_server=info,actix_web=info");
env_logger::init();
let sys = actix_rt::System::new("hello-world");
HttpServer::new(|| {
App::new()
.middleware(middleware::DefaultHeaders::new().header("X-Version", "0.2"))
.middleware(middleware::Compress::default())
.middleware(middleware::Logger::default())
.service(index)
.service(no_params)
.service(
@ -44,7 +44,5 @@ fn main() -> std::io::Result<()> {
})
.bind("127.0.0.1:8080")?
.workers(1)
.start();
sys.run()
.run()
}