2018-04-13 03:18:42 +02:00
|
|
|
extern crate actix;
|
|
|
|
extern crate actix_web;
|
|
|
|
extern crate env_logger;
|
|
|
|
extern crate tokio_uds;
|
|
|
|
|
|
|
|
use actix::*;
|
|
|
|
use actix_web::{middleware, server, App, HttpRequest};
|
|
|
|
use tokio_uds::UnixListener;
|
|
|
|
|
2018-07-16 08:36:53 +02:00
|
|
|
fn index(_req: &HttpRequest) -> &'static str {
|
2018-04-13 03:18:42 +02:00
|
|
|
"Hello world!"
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
::std::env::set_var("RUST_LOG", "actix_web=info");
|
|
|
|
env_logger::init();
|
|
|
|
let sys = actix::System::new("unix-socket");
|
|
|
|
|
2018-07-16 08:36:53 +02:00
|
|
|
let listener = UnixListener::bind("/tmp/actix-uds.socket").expect("bind failed");
|
2018-05-08 20:08:43 +02:00
|
|
|
server::new(|| {
|
|
|
|
App::new()
|
2018-04-13 03:18:42 +02:00
|
|
|
// enable logger
|
|
|
|
.middleware(middleware::Logger::default())
|
|
|
|
.resource("/index.html", |r| r.f(|_| "Hello world!"))
|
2018-05-08 20:08:43 +02:00
|
|
|
.resource("/", |r| r.f(index))
|
|
|
|
}).start_incoming(listener.incoming(), false);
|
2018-04-13 03:18:42 +02:00
|
|
|
|
|
|
|
println!("Started http server: /tmp/actix-uds.socket");
|
|
|
|
let _ = sys.run();
|
|
|
|
}
|