From 4f9bc9ef9dc3ff934d2786656edcf2a971d4fe6f Mon Sep 17 00:00:00 2001 From: Bill Thiede Date: Sun, 13 Nov 2022 15:42:23 -0800 Subject: [PATCH] server: version bump and cleanup. --- server/Cargo.toml | 12 ++++++------ server/src/main.rs | 18 ++++++++++-------- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/server/Cargo.toml b/server/Cargo.toml index 4a772f9..296faef 100644 --- a/server/Cargo.toml +++ b/server/Cargo.toml @@ -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"] diff --git a/server/src/main.rs b/server/src/main.rs index 88dca04..b2537d6 100644 --- a/server/src/main.rs +++ b/server/src/main.rs @@ -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/")] -async fn original(nm: &State, id: &str) -> Result>, Debug> { +async fn original( + nm: &State, + id: &str, +) -> Result<(ContentType, Vec), Debug> { 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> { } .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?;