2019-03-10 07:38:15 +01:00
|
|
|
use actix_web::{middleware, web, App, HttpRequest, HttpServer};
|
2018-04-13 03:18:42 +02:00
|
|
|
|
2019-03-10 07:38:15 +01:00
|
|
|
fn index(req: HttpRequest) -> &'static str {
|
|
|
|
println!("REQ: {:?}", req);
|
2018-04-13 03:18:42 +02:00
|
|
|
"Hello world!"
|
|
|
|
}
|
|
|
|
|
2019-03-10 07:38:15 +01:00
|
|
|
fn main() -> std::io::Result<()> {
|
|
|
|
std::env::set_var("RUST_LOG", "actix_web=info");
|
2018-04-13 03:18:42 +02:00
|
|
|
env_logger::init();
|
|
|
|
|
2019-03-10 07:38:15 +01:00
|
|
|
HttpServer::new(|| {
|
2018-05-08 20:08:43 +02:00
|
|
|
App::new()
|
2018-04-13 03:18:42 +02:00
|
|
|
// enable logger
|
2019-03-26 04:29:00 +01:00
|
|
|
.wrap(middleware::Logger::default())
|
2019-03-10 07:38:15 +01:00
|
|
|
.service(web::resource("/index.html").to(|| "Hello world!"))
|
|
|
|
.service(web::resource("/").to(index))
|
2019-03-10 03:03:09 +01:00
|
|
|
})
|
2019-03-10 07:38:15 +01:00
|
|
|
.bind("127.0.0.1:8080")?
|
|
|
|
.run()
|
2018-04-13 03:18:42 +02:00
|
|
|
}
|