server: version bump and cleanup.
This commit is contained in:
parent
1477980395
commit
4f9bc9ef9d
@ -6,15 +6,15 @@ edition = "2021"
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
rocket = { version = "0.5.0-rc.1", features = [ "json" ] }
|
||||
rocket = { version = "0.5.0-rc.2", features = [ "json" ] }
|
||||
rocket_cors = { git = "https://github.com/lawliet89/rocket_cors", branch = "master" }
|
||||
notmuch = { path = "../notmuch" }
|
||||
serde_json = "1.0.64"
|
||||
thiserror = "1.0.26"
|
||||
serde = { version = "1.0", features = ["derive"] }
|
||||
log = "0.4.14"
|
||||
serde_json = "1.0.87"
|
||||
thiserror = "1.0.37"
|
||||
serde = { version = "1.0.147", features = ["derive"] }
|
||||
log = "0.4.17"
|
||||
|
||||
[dependencies.rocket_contrib]
|
||||
version = "0.4.10"
|
||||
version = "0.4.11"
|
||||
default-features = false
|
||||
features = ["json"]
|
||||
|
||||
@ -3,17 +3,16 @@ extern crate rocket;
|
||||
|
||||
use std::{error::Error, io::Cursor, str::FromStr};
|
||||
|
||||
use notmuch::{Notmuch, NotmuchError, SearchSummary, ThreadSet};
|
||||
use rocket::{
|
||||
http::{ContentType, Header},
|
||||
request::Request,
|
||||
response::{content::Plain, Debug, Responder},
|
||||
response::{Debug, Responder},
|
||||
serde::json::Json,
|
||||
Response, State,
|
||||
};
|
||||
use rocket_cors::{AllowedHeaders, AllowedOrigins};
|
||||
|
||||
use notmuch::{Notmuch, NotmuchError, SearchSummary, ThreadSet};
|
||||
|
||||
#[get("/")]
|
||||
fn hello() -> &'static str {
|
||||
"Hello, world!"
|
||||
@ -75,14 +74,17 @@ async fn original_part(
|
||||
}
|
||||
|
||||
#[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<(ContentType, 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(Plain(res))
|
||||
Ok((ContentType::Plain, res))
|
||||
}
|
||||
|
||||
#[rocket::main]
|
||||
@ -100,11 +102,11 @@ async fn main() -> Result<(), Box<dyn Error>> {
|
||||
}
|
||||
.to_cors()?;
|
||||
|
||||
rocket::build()
|
||||
let _ = rocket::build()
|
||||
.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?;
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user