summaryrefslogtreecommitdiffstats
path: root/service-world/src
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2021-10-03 11:35:33 +0200
committerMatthias Beyer <mail@beyermatthias.de>2021-10-03 18:55:12 +0200
commit81dba4625add1fdf537eacd8108aac0042fbf34b (patch)
treeb4234104f76a699c64bac24df8bfe83ea1abcd29 /service-world/src
Initial import
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
Diffstat (limited to 'service-world/src')
-rw-r--r--service-world/src/main.rs26
1 files changed, 26 insertions, 0 deletions
diff --git a/service-world/src/main.rs b/service-world/src/main.rs
new file mode 100644
index 0000000..6feef85
--- /dev/null
+++ b/service-world/src/main.rs
@@ -0,0 +1,26 @@
+use std::str::FromStr;
+
+use anyhow::Context;
+use actix_web::{get, App, HttpServer, Responder};
+
+#[get("/")]
+async fn world() -> impl Responder {
+ "World"
+}
+
+#[actix_web::main]
+async fn main() -> anyhow::Result<()> {
+ env_logger::init_from_env(env_logger::Env::new().default_filter_or("info"));
+ let bind = std::env::var("HOST").expect("environment: HOST variable not set");
+ let port = std::env::var("PORT")
+ .as_ref()
+ .map(|p| u16::from_str(p))
+ .expect("environment: PORT variable not set")
+ .context("Failed to parse port as integer")?;
+
+ HttpServer::new(|| App::new().service(world))
+ .bind(format!("{}:{}", bind, port))?
+ .run()
+ .await
+ .map_err(anyhow::Error::from)
+}