chiark / gitweb /
actix cleanup: Remove actix test programs
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 27 Mar 2022 22:41:12 +0000 (23:41 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 27 Mar 2022 23:50:50 +0000 (00:50 +0100)
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
TODO
daemon/Cargo.toml
daemon/actix-files-example.rs [deleted file]
daemon/actix-test.rs [deleted file]

diff --git a/TODO b/TODO
index f28dc6231953c0a7fda0fbf02567f31c07bfda8c..9fd8a5daea3838317ab0be4af7f2b3c5ff1008d4 100644 (file)
--- a/TODO
+++ b/TODO
@@ -1,4 +1,3 @@
-remove test programs
 template render failure logging
 template don't do */* thing, and strip .tera
 TODOs in diff
index bdbe4a4c5a0ba6f6e935e618700aca865af5d88b..88d49c2ded2a1754ed844452584f61fb7ab2f3a7 100644 (file)
@@ -19,14 +19,6 @@ authors=["Ian Jackson <ijackson@chiark.greenend.org.uk>",
 name="daemon-otter"
 path="main.rs"
 
-[[bin]]
-name="actix-test"
-path="actix-test.rs"
-
-[[bin]]
-name="actix-files-example"
-path="actix-files-example.rs"
-
 
 [dependencies]
 
diff --git a/daemon/actix-files-example.rs b/daemon/actix-files-example.rs
deleted file mode 100644 (file)
index d4daa1e..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-use actix_files::Files;
-use actix_web::{middleware::Logger, App, HttpServer};
-use actix_web::{get, Responder, HttpResponse};
-use otter::imports::*;
-
-#[get("/wombat")]
-async fn wombat() -> impl Responder {
-  HttpResponse::Ok().body("WOMBAT\n")
-}
-
-#[actix_web::main]
-async fn main() -> std::io::Result<()> {
-    env_logger::init_from_env(env_logger::Env::new().default_filter_or("info"));
-
-    log::info!("starting HTTP server at http://localhost:8080");
-
-    HttpServer::new(|| {
-        App::new()
-            // We allow the visitor to see an index of the images at `/images`.
-            .service(wombat)
-            .service(Files::new("/images", "static/images/").show_files_listing())
-            // Serve a tree of static files at the web root and specify the index file.
-            // Note that the root path should always be defined as the last item. The paths are
-            // resolved in the order they are defined. If this would be placed before the `/images`
-            // path then the service for the static images would never be reached.
-            .service(Files::new("/", "./static/root/").index_file("index.html"))
-            // Enable the logger.
-            .wrap(Logger::default())
-    })
-    .bind(("127.0.0.1", 8080))?
-    .run()
-    .await
-}
diff --git a/daemon/actix-test.rs b/daemon/actix-test.rs
deleted file mode 100644 (file)
index 27c71b6..0000000
+++ /dev/null
@@ -1,90 +0,0 @@
-
-#![allow(unused_imports)]
-
-use actix_web::{get, head, web, route, App, HttpServer, Responder};
-use actix_web::FromRequest;
-use actix_web::HttpRequest;
-use actix_web::http::Method;
-use actix_web::HttpResponse;
-use actix_web::dev::Payload;
-use actix_web::middleware;
-use actix_cors::Cors;
-
-use std::convert::Infallible;
-
-//use otter::imports::*;
-
-//use futures::Future;
-
-#[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)
-}
-
-#[derive(Debug, Default)]
-struct Remain {
-  #[allow(dead_code)]
-  q: Option<String>,
-}
-
-impl FromRequest for Remain {
-  type Future = futures::future::Ready<Result<Remain, Infallible>>;
-  type Error = Infallible;
-  fn from_request(req: &HttpRequest, _: &mut Payload)
-                  -> Self::Future {
-    let q = req.uri().query().map(ToOwned::to_owned);
-    let r = Remain { q };
-    futures::future::ready(Ok(r))
-  }
-}
-
-//#[route("/wombat", method="GET", method="HEAD")]
-#[get("/wombat")]
-async fn wombat(remain: Remain) -> impl Responder {
-    format!("Hello {:?}", remain)
-}
-
-fn update_cors() -> Cors {
-  Cors::default()
-      .allowed_methods([Method::GET])
-
-}
-
-//#[route("/wombat", method="GET", method="HEAD")]
-#[route("/foo", method="GET", method="HEAD",
-        wrap = "update_cors()")]
-//#[get("/foo")]
-async fn foo() -> impl Responder {
-  "foo\r\n"
-}
-
-use fehler::throws;
-async fn not_found_handler(method: Method) -> impl Responder {
-  match method {
-    Method::GET | Method::HEAD => HttpResponse::NotFound()
-      .content_type("text/plain; charset=utf-8")
-      .body("Not found.")
-    ,
-    _  => HttpResponse::MethodNotAllowed().finish(),
-  }
-}
-
-#[actix_web::main] // or #[tokio::main]
-async fn main() -> std::io::Result<()> {
-  HttpServer::new(|| App::new()
-                  .service(wombat)
-                  .service(index)
-                  .service(foo)
-                  .default_service(web::to(not_found_handler))
-                  .wrap(
-middleware::DefaultHeaders::new().add((
-  actix_web::http::header::X_CONTENT_TYPE_OPTIONS,
-  "nosniff"
-))
-                  )
-  )
-    .bind(("127.0.0.1", 8080))?
-    .run()
-    .await
-}