2020-02-24 10:48:04 -07:00
|
|
|
#[macro_use]
|
|
|
|
extern crate actix_web;
|
|
|
|
|
2020-04-03 16:14:30 +09:00
|
|
|
use actix_web::{App, HttpResponse, HttpServer, Responder};
|
2020-02-24 10:48:04 -07:00
|
|
|
|
|
|
|
#[get("/")]
|
|
|
|
async fn index() -> impl Responder {
|
|
|
|
println!("GET: /");
|
|
|
|
HttpResponse::Ok().body("Hello world!")
|
|
|
|
}
|
|
|
|
|
|
|
|
#[get("/again")]
|
|
|
|
async fn again() -> impl Responder {
|
|
|
|
println!("GET: /again");
|
|
|
|
HttpResponse::Ok().body("Hello world again!")
|
|
|
|
}
|
|
|
|
|
|
|
|
#[actix_rt::main]
|
|
|
|
async fn main() -> std::io::Result<()> {
|
|
|
|
println!("Starting actix-web server");
|
|
|
|
|
2020-04-03 16:16:17 +09:00
|
|
|
HttpServer::new(|| App::new().service(index).service(again))
|
|
|
|
.bind("0.0.0.0:5000")?
|
|
|
|
.run()
|
|
|
|
.await
|
|
|
|
}
|
2020-05-27 22:01:26 +02:00
|
|
|
|
|
|
|
#[cfg(test)]
|
|
|
|
mod tests {
|
|
|
|
#[test]
|
|
|
|
fn sample_test() {
|
|
|
|
assert!(true);
|
|
|
|
}
|
|
|
|
}
|