Simplify cli option, add channel search

This commit is contained in:
Dominik Werder
2021-05-27 16:23:38 +02:00
parent e55751ad67
commit 53957a261a
9 changed files with 155 additions and 22 deletions

12
httpret/src/search.rs Normal file
View File

@@ -0,0 +1,12 @@
use err::Error;
use hyper::{Body, Request, Response, StatusCode};
use netpod::{ChannelSearchQuery, NodeConfigCached};
pub async fn channel_search(req: Request<Body>, node_config: &NodeConfigCached) -> Result<Response<Body>, Error> {
let (head, _body) = req.into_parts();
let query = ChannelSearchQuery::from_request(head.uri.query())?;
let res = dbconn::search::search_channel(query, node_config).await?;
let body = Body::from(serde_json::to_string(&res)?);
let ret = super::response(StatusCode::OK).body(body)?;
Ok(ret)
}