.body(cursor.into_inner()))
}
+#[get("/pdrop/{canvas_id}")]
+async fn pdrop(canvas_id: web::Path<u8>, canvas0: web::Data<Arc<Mutex<Canvas0>>>, canvas1: web::Data<Arc<Mutex<Canvas1>>>) -> Result<impl Responder> {
+ let canvas_id = canvas_id.into_inner();
+ match canvas_id {
+ 0 => canvas0.lock().unwrap().0.take(),
+ 1 => canvas1.lock().unwrap().0.take(),
+ _ => None
+ }.ok_or_else( || CanvasError::NotExists )?;
+ Ok(HttpResponse::build(StatusCode::OK)
+ .body(format!("Canvas {} dropped.", canvas_id)))
+}
+
#[actix_web::main] // or #[tokio::main]
async fn main() -> std::io::Result<()> {
.service(img_gen1)
.service(img_pgen0)
.service(img_pgen1)
+ .service(pdrop)
.app_data(web::Data::new(canvas0.clone()))
.app_data(web::Data::new(canvas1.clone()))
})