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 rocket::{response::Debug, serde::json::Json, State};
|
||||
use rocket::{
|
||||
response::{content::Plain, Debug},
|
||||
serde::json::Json,
|
||||
State,
|
||||
};
|
||||
use rocket_cors::{AllowedHeaders, AllowedOrigins};
|
||||
|
||||
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>")]
|
||||
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:") {
|
||||
id.to_string()
|
||||
} else {
|
||||
format!("id:{}", id)
|
||||
};
|
||||
let res = nm.show_original(&mid)?;
|
||||
Ok(res)
|
||||
Ok(Plain(res))
|
||||
}
|
||||
|
||||
#[rocket::main]
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user