2022-01-27 02:58:13 +00:00
|
|
|
use actix_web::{get, middleware::Logger, App, HttpResponse, HttpServer, Responder};
|
2020-02-24 10:48:04 -07:00
|
|
|
|
|
|
|
#[get("/")]
|
|
|
|
async fn index() -> impl Responder {
|
|
|
|
HttpResponse::Ok().body("Hello world!")
|
|
|
|
}
|
|
|
|
|
|
|
|
#[get("/again")]
|
|
|
|
async fn again() -> impl Responder {
|
|
|
|
HttpResponse::Ok().body("Hello world again!")
|
|
|
|
}
|
|
|
|
|
2020-09-12 16:49:45 +01:00
|
|
|
#[actix_web::main]
|
2020-02-24 10:48:04 -07:00
|
|
|
async fn main() -> std::io::Result<()> {
|
2022-01-27 02:58:13 +00:00
|
|
|
env_logger::init_from_env(env_logger::Env::new().default_filter_or("info"));
|
|
|
|
|
|
|
|
log::info!("Starting HTTP server: go to http://localhost:8080");
|
2020-02-24 10:48:04 -07:00
|
|
|
|
2022-01-27 02:58:13 +00:00
|
|
|
HttpServer::new(|| {
|
|
|
|
App::new()
|
|
|
|
.wrap(Logger::default())
|
|
|
|
.service(index)
|
|
|
|
.service(again)
|
|
|
|
})
|
|
|
|
.bind(("0.0.0.0", 8080))?
|
|
|
|
.run()
|
|
|
|
.await
|
2020-04-03 16:16:17 +09:00
|
|
|
}
|