forked from actix/actix-web
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Unix domain sockets (HttpServer::bind_uds) actix#92
- Loading branch information
Showing
9 changed files
with
108 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
use futures::IntoFuture; | ||
|
||
use actix_web::{ | ||
get, middleware, web, App, Error, HttpRequest, HttpResponse, HttpServer, | ||
}; | ||
|
||
#[get("/resource1/{name}/index.html")] | ||
fn index(req: HttpRequest, name: web::Path<String>) -> String { | ||
println!("REQ: {:?}", req); | ||
format!("Hello: {}!\r\n", name) | ||
} | ||
|
||
fn index_async(req: HttpRequest) -> impl IntoFuture<Item = &'static str, Error = Error> { | ||
println!("REQ: {:?}", req); | ||
Ok("Hello world!\r\n") | ||
} | ||
|
||
#[get("/")] | ||
fn no_params() -> &'static str { | ||
"Hello world!\r\n" | ||
} | ||
|
||
fn main() -> std::io::Result<()> { | ||
std::env::set_var("RUST_LOG", "actix_server=info,actix_web=info"); | ||
env_logger::init(); | ||
|
||
HttpServer::new(|| { | ||
App::new() | ||
.wrap(middleware::DefaultHeaders::new().header("X-Version", "0.2")) | ||
.wrap(middleware::Compress::default()) | ||
.wrap(middleware::Logger::default()) | ||
.service(index) | ||
.service(no_params) | ||
.service( | ||
web::resource("/resource2/index.html") | ||
.wrap( | ||
middleware::DefaultHeaders::new().header("X-Version-R2", "0.3"), | ||
) | ||
.default_service( | ||
web::route().to(|| HttpResponse::MethodNotAllowed()), | ||
) | ||
.route(web::get().to_async(index_async)), | ||
) | ||
.service(web::resource("/test1.html").to(|| "Test\r\n")) | ||
}) | ||
.bind_uds("/Users/fafhrd91/uds-test")? | ||
.workers(1) | ||
.run() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[package] | ||
name = "actix-http-test" | ||
version = "0.2.3" | ||
version = "0.2.4" | ||
authors = ["Nikolay Kim <[email protected]>"] | ||
description = "Actix http test server" | ||
readme = "README.md" | ||
|
@@ -33,7 +33,7 @@ ssl = ["openssl", "actix-server/ssl", "awc/ssl"] | |
actix-codec = "0.1.2" | ||
actix-rt = "0.2.2" | ||
actix-service = "0.4.1" | ||
actix-server = "0.5.1" | ||
actix-server = "0.6.0" | ||
actix-utils = "0.4.1" | ||
awc = "0.2.2" | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters