server: set content type when viewing original to prevent download.
This commit is contained in:
parent
b8a622dba5
commit
db0e7c2005
@ -3,7 +3,11 @@ extern crate rocket;
|
|||||||
|
|
||||||
use std::{error::Error, process::Command, str::FromStr};
|
use std::{error::Error, process::Command, str::FromStr};
|
||||||
|
|
||||||
use rocket::{response::Debug, serde::json::Json, State};
|
use rocket::{
|
||||||
|
response::{content::Plain, Debug},
|
||||||
|
serde::json::Json,
|
||||||
|
State,
|
||||||
|
};
|
||||||
use rocket_cors::{AllowedHeaders, AllowedOrigins};
|
use rocket_cors::{AllowedHeaders, AllowedOrigins};
|
||||||
|
|
||||||
use notmuch::{MessageId, Notmuch, NotmuchError, SearchSummary, ThreadSet};
|
use notmuch::{MessageId, Notmuch, NotmuchError, SearchSummary, ThreadSet};
|
||||||
@ -29,14 +33,14 @@ async fn show(nm: &State<Notmuch>, query: &str) -> Result<Json<ThreadSet>, Debug
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[get("/original/<id>")]
|
#[get("/original/<id>")]
|
||||||
async fn original(nm: &State<Notmuch>, id: &str) -> Result<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:") {
|
||||||
id.to_string()
|
id.to_string()
|
||||||
} else {
|
} else {
|
||||||
format!("id:{}", id)
|
format!("id:{}", id)
|
||||||
};
|
};
|
||||||
let res = nm.show_original(&mid)?;
|
let res = nm.show_original(&mid)?;
|
||||||
Ok(res)
|
Ok(Plain(res))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[rocket::main]
|
#[rocket::main]
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user