From: Ian Jackson Date: Fri, 26 Jun 2020 20:33:12 +0000 (+0100) Subject: receives api grab request X-Git-Tag: otter-0.2.0~1552 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=9f8dd3b99df5fe567811cf20dfcff7c6d11a43d9;p=otter.git receives api grab request --- diff --git a/src/bin/server.rs b/src/bin/server.rs index 7b3fe4bf..301fcb27 100644 --- a/src/bin/server.rs +++ b/src/bin/server.rs @@ -109,6 +109,19 @@ fn session(form : Json) -> Result { Ok(Template::render("test",&c)) } +#[derive(Debug,Serialize,Deserialize)] +struct ApiGrab { + t : String, + p : String, +} + +#[post("/_/api/grab", format="json", data="
")] +#[throws(RE)] +fn api(form : Json) -> 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(); } diff --git a/templates/script.js b/templates/script.js index f7d54838..17d3b381 100644 --- a/templates/script.js +++ b/templates/script.js @@ -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) {