From f809f89dd06897e9b5213057ce6e7ef24093885d Mon Sep 17 00:00:00 2001 From: Bill Thiede Date: Mon, 8 Nov 2021 21:06:45 -0800 Subject: [PATCH] server: add URL for downloading attachments. --- server/src/main.rs | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/server/src/main.rs b/server/src/main.rs index 899e34e..7523b5f 100644 --- a/server/src/main.rs +++ b/server/src/main.rs @@ -32,6 +32,21 @@ async fn show(nm: &State, query: &str) -> Result, Debug Ok(Json(res)) } +#[get("/original//part/")] +async fn original_part( + nm: &State, + id: &str, + part: usize, +) -> Result, Debug> { + let mid = if id.starts_with("id:") { + id.to_string() + } else { + format!("id:{}", id) + }; + let res = nm.show_original_part(&mid, part)?; + Ok(res) +} + #[get("/original/")] async fn original(nm: &State, id: &str) -> Result>, Debug> { let mid = if id.starts_with("id:") { @@ -59,10 +74,10 @@ async fn main() -> Result<(), Box> { .to_cors()?; rocket::build() - .mount("/", routes![original, hello, search, show]) + .mount("/", routes![original_part, original, hello, search, show]) .attach(cors) - .manage(Notmuch::default()) - //.manage(Notmuch::with_config("../notmuch/testdata/notmuch.config")) + //.manage(Notmuch::default()) + .manage(Notmuch::with_config("../notmuch/testdata/notmuch.config")) .launch() .await?;