From cef9ddc61e888902b5ecea52c3dd425a63cd4d0c Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Sun, 6 Mar 2022 13:07:39 +0000 Subject: [PATCH] actix: experiments: A test example program for playing with C&P from Actix docs. Not adding to copyright/licence tracking since I am going to remove this again. Signed-off-by: Ian Jackson --- TODO | 1 + daemon/Cargo.toml | 4 ++++ daemon/actix-test.rs | 16 ++++++++++++++++ 3 files changed, 21 insertions(+) create mode 100644 TODO create mode 100644 daemon/actix-test.rs diff --git a/TODO b/TODO new file mode 100644 index 00000000..5f618d1c --- /dev/null +++ b/TODO @@ -0,0 +1 @@ +remove test programs diff --git a/daemon/Cargo.toml b/daemon/Cargo.toml index 9edd16d3..154fbe1c 100644 --- a/daemon/Cargo.toml +++ b/daemon/Cargo.toml @@ -19,6 +19,10 @@ authors=["Ian Jackson ", name="daemon-otter" path="main.rs" +[[bin]] +name="actix-test" +path="actix-test.rs" + [dependencies] diff --git a/daemon/actix-test.rs b/daemon/actix-test.rs new file mode 100644 index 00000000..42022d1d --- /dev/null +++ b/daemon/actix-test.rs @@ -0,0 +1,16 @@ + +use actix_web::{get, web, App, HttpServer, Responder}; + +#[get("/{id}/{name}/index.html")] +async fn index(params: web::Path<(u32, String)>) -> impl Responder { + let (id, name) = params.into_inner(); + format!("Hello {}! id:{}", name, id) +} + +#[actix_web::main] // or #[tokio::main] +async fn main() -> std::io::Result<()> { + HttpServer::new(|| App::new().service(index)) + .bind(("127.0.0.1", 8080))? + .run() + .await +} -- 2.30.2