server: add URL for downloading attachments.
This commit is contained in:
parent
bd14616069
commit
f809f89dd0
@ -32,6 +32,21 @@ async fn show(nm: &State<Notmuch>, query: &str) -> Result<Json<ThreadSet>, Debug
|
|||||||
Ok(Json(res))
|
Ok(Json(res))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[get("/original/<id>/part/<part>")]
|
||||||
|
async fn original_part(
|
||||||
|
nm: &State<Notmuch>,
|
||||||
|
id: &str,
|
||||||
|
part: usize,
|
||||||
|
) -> Result<Vec<u8>, Debug<NotmuchError>> {
|
||||||
|
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/<id>")]
|
#[get("/original/<id>")]
|
||||||
async fn original(nm: &State<Notmuch>, id: &str) -> Result<Plain<Vec<u8>>, Debug<NotmuchError>> {
|
async fn original(nm: &State<Notmuch>, id: &str) -> Result<Plain<Vec<u8>>, Debug<NotmuchError>> {
|
||||||
let mid = if id.starts_with("id:") {
|
let mid = if id.starts_with("id:") {
|
||||||
@ -59,10 +74,10 @@ async fn main() -> Result<(), Box<dyn Error>> {
|
|||||||
.to_cors()?;
|
.to_cors()?;
|
||||||
|
|
||||||
rocket::build()
|
rocket::build()
|
||||||
.mount("/", routes![original, hello, search, show])
|
.mount("/", routes![original_part, original, hello, search, show])
|
||||||
.attach(cors)
|
.attach(cors)
|
||||||
.manage(Notmuch::default())
|
//.manage(Notmuch::default())
|
||||||
//.manage(Notmuch::with_config("../notmuch/testdata/notmuch.config"))
|
.manage(Notmuch::with_config("../notmuch/testdata/notmuch.config"))
|
||||||
.launch()
|
.launch()
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user