1
0
mirror of https://github.com/actix/examples synced 2025-06-26 09:17:41 +02:00

Restructure folders (#411)

This commit is contained in:
Daniel T. Rodrigues
2021-02-25 21:57:58 -03:00
committed by GitHub
parent 9db98162b2
commit c3407627d0
334 changed files with 127 additions and 120 deletions

View File

@ -1,9 +0,0 @@
[package]
name = "unix-socket"
version = "1.0.0"
authors = ["Messense Lv <messense@icloud.com>"]
edition = "2018"
[dependencies]
env_logger = "0.8"
actix-web = "3"

View File

@ -1,14 +0,0 @@
## Unix domain socket example
```bash
$ curl --unix-socket /tmp/actix-uds.socket http://localhost/
Hello world!
```
Although this will only one thread for handling incoming connections
according to the
[documentation](https://actix.github.io/actix-web/actix_web/struct.HttpServer.html#method.bind_uds).
And it does not delete the socket file (`/tmp/actix-uds.socket`) when stopping
the server so it will fail to start next time you run it unless you delete
the socket file manually.

View File

@ -1,32 +0,0 @@
use actix_web::{middleware, web, App, HttpRequest, HttpServer};
async fn index(_req: HttpRequest) -> &'static str {
"Hello world!"
}
#[actix_web::main]
#[cfg(unix)]
async fn main() -> std::io::Result<()> {
::std::env::set_var("RUST_LOG", "actix_server=info,actix_web=info");
env_logger::init();
HttpServer::new(|| {
App::new()
// enable logger - always register actix-web Logger middleware last
.wrap(middleware::Logger::default())
.service(
web::resource("/index.html")
.route(web::get().to(|| async { "Hello world!" })),
)
.service(web::resource("/").to(index))
})
.bind_uds("/tmp/actix-uds.socket")?
.run()
.await
}
#[cfg(not(unix))]
fn main() -> std::io::Result<()> {
println!("not supported");
Ok(())
}