diff --git a/server/src/main.rs b/server/src/main.rs index 89c728a..363604e 100644 --- a/server/src/main.rs +++ b/server/src/main.rs @@ -6,7 +6,7 @@ use std::{error::Error, process::Command, str::FromStr}; use rocket::{response::Debug, serde::json::Json, State}; use rocket_cors::{AllowedHeaders, AllowedOrigins}; -use notmuch::{Notmuch, NotmuchError, SearchSummary, ThreadSet}; +use notmuch::{MessageId, Notmuch, NotmuchError, SearchSummary, ThreadSet}; #[get("/")] fn hello() -> &'static str { @@ -28,6 +28,17 @@ async fn show(nm: &State, query: &str) -> Result, Debug Ok(Json(res)) } +#[get("/original/")] +async fn original(nm: &State, id: &str) -> Result, Debug> { + let mid = if id.starts_with("id:") { + id.to_string() + } else { + format!("id:{}", id) + }; + let res = nm.show_original(&mid)?; + Ok(res) +} + #[rocket::main] async fn main() -> Result<(), Box> { let allowed_origins = AllowedOrigins::all(); @@ -44,9 +55,10 @@ async fn main() -> Result<(), Box> { .to_cors()?; rocket::build() - .mount("/", routes![hello, search, show]) + .mount("/", routes![original, hello, search, show]) .attach(cors) - .manage(Notmuch::with_config("../notmuch/testdata/notmuch.config")) + .manage(Notmuch::default()) + //.manage(Notmuch::with_config("../notmuch/testdata/notmuch.config")) .launch() .await?;