WIP
This commit is contained in:
@@ -1,10 +1,12 @@
|
||||
#[macro_use]
|
||||
extern crate rocket;
|
||||
mod error;
|
||||
mod nm;
|
||||
|
||||
use std::{error::Error, io::Cursor, str::FromStr};
|
||||
|
||||
use glog::Flags;
|
||||
use notmuch::{Notmuch, NotmuchError, ThreadSet};
|
||||
use notmuch::{Notmuch, NotmuchError};
|
||||
use rocket::{
|
||||
http::{ContentType, Header},
|
||||
request::Request,
|
||||
@@ -14,6 +16,8 @@ use rocket::{
|
||||
};
|
||||
use rocket_cors::{AllowedHeaders, AllowedOrigins};
|
||||
|
||||
use crate::error::ServerError;
|
||||
|
||||
#[get("/")]
|
||||
fn hello() -> &'static str {
|
||||
"Hello, world!"
|
||||
@@ -52,8 +56,11 @@ async fn search(
|
||||
}
|
||||
|
||||
#[get("/show/<query>")]
|
||||
async fn show(nm: &State<Notmuch>, query: &str) -> Result<Json<ThreadSet>, Debug<NotmuchError>> {
|
||||
let res = nm.show(query)?;
|
||||
async fn show(
|
||||
nm: &State<Notmuch>,
|
||||
query: &str,
|
||||
) -> Result<Json<Vec<shared::Message>>, Debug<ServerError>> {
|
||||
let res = nm::threadset_to_messages(nm.show(query).map_err(|e| -> ServerError { e.into() })?)?;
|
||||
Ok(Json(res))
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user