1
0
mirror of https://github.com/actix/examples synced 2024-11-30 17:14:35 +01:00
examples/unix-socket/src/main.rs

23 lines
672 B
Rust
Raw Normal View History

2019-07-18 14:03:19 +02:00
use actix_web::{middleware, web, App, HttpRequest, HttpServer};
2019-07-18 14:03:19 +02:00
fn index(_req: HttpRequest) -> &'static str {
"Hello world!"
}
2019-07-18 14:03:19 +02:00
fn main() -> std::io::Result<()> {
::std::env::set_var("RUST_LOG", "actix_server=info,actix_web=info");
env_logger::init();
2019-07-18 14:03:19 +02:00
HttpServer::new(|| {
2018-05-08 20:08:43 +02:00
App::new()
2019-07-18 14:03:19 +02:00
// enable logger - always register actix-web Logger middleware last
.wrap(middleware::Logger::default())
.service(
web::resource("/index.html").route(web::get().to(|| "Hello world!")),
)
.service(web::resource("/").to(index))
2019-03-10 03:03:09 +01:00
})
2019-07-18 14:03:19 +02:00
.bind_uds("/tmp/actix-uds.socket")?
.run()
}