chiark / gitweb /
receives api grab request
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Fri, 26 Jun 2020 20:33:12 +0000 (21:33 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Fri, 26 Jun 2020 20:33:12 +0000 (21:33 +0100)
src/bin/server.rs
templates/script.js

index 7b3fe4bfff909945188b21ea2c1ed20917ae90a8..301fcb277370a438c6acf6cb240e984614a73bb2 100644 (file)
@@ -109,6 +109,19 @@ fn session(form : Json<SessionForm>) -> Result<Template,RE> {
   Ok(Template::render("test",&c))
 }
 
+#[derive(Debug,Serialize,Deserialize)]
+struct ApiGrab {
+  t : String,
+  p : String,
+}
+
+#[post("/_/api/grab", format="json", data="<form>")]
+#[throws(RE)]
+fn api(form : Json<ApiGrab>) -> impl response::Responder<'static> {
+  eprintln!("API {:?}", &form);
+  ""
+}
+
 #[derive(Serialize)]
 enum Update {
   TestCounter { value: usize },
@@ -180,6 +193,7 @@ fn main() {
       session,
       resource,
       updates,
+      api,
     ])
     .launch();
 }
index f7d54838cb3480c0cf6d802258a1ed0cff0bc45e..17d3b3813abd02109f3731af69398817f557d712 100644 (file)
@@ -45,7 +45,10 @@ function drag_mousedown(e) {
   dragging = false;
   window.addEventListener('mousemove', drag_mousemove, true);
   window.addEventListener('mouseup',   drag_mouseup,   true);
-  
+  xhr_post_then('/_/api/grab',JSON.stringify({
+    t : token,
+    p : delt.dataset.p,
+  }), function(){ });
 }
 
 function drag_mousemove(e) {