2018-01-02 22:42:30 +01:00
|
|
|
extern crate actix;
|
|
|
|
extern crate actix_web;
|
|
|
|
extern crate env_logger;
|
|
|
|
|
2018-03-31 03:54:38 +02:00
|
|
|
use actix_web::{Application, HttpRequest, server, middleware};
|
2018-01-02 22:42:30 +01:00
|
|
|
|
|
|
|
|
|
|
|
fn index(_req: HttpRequest) -> &'static str {
|
|
|
|
"Hello world!"
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
::std::env::set_var("RUST_LOG", "actix_web=info");
|
|
|
|
let _ = env_logger::init();
|
|
|
|
let sys = actix::System::new("ws-example");
|
|
|
|
|
2018-03-31 03:54:38 +02:00
|
|
|
let _addr = server::new(
|
2018-01-02 22:42:30 +01:00
|
|
|
|| Application::new()
|
|
|
|
// enable logger
|
|
|
|
.middleware(middleware::Logger::default())
|
|
|
|
.resource("/index.html", |r| r.f(|_| "Hello world!"))
|
|
|
|
.resource("/", |r| r.f(index)))
|
|
|
|
.bind("127.0.0.1:8080").unwrap()
|
|
|
|
.start();
|
|
|
|
|
|
|
|
println!("Started http server: 127.0.0.1:8080");
|
|
|
|
let _ = sys.run();
|
|
|
|
}
|