Simplify and fix channel search query parse

This commit is contained in:
Dominik Werder
2021-06-22 16:57:51 +02:00
parent 5219b56488
commit d0318a17c2
6 changed files with 33 additions and 254 deletions

View File

@@ -1,6 +1,7 @@
use crate::response;
use err::Error;
use hyper::{Body, Request, Response, StatusCode};
use netpod::log::*;
use netpod::{ChannelSearchQuery, NodeConfigCached};
use url::Url;
@@ -9,10 +10,10 @@ pub async fn channel_search(req: Request<Body>, node_config: &NodeConfigCached)
match head.headers.get("accept") {
Some(v) if v == "application/json" => {
let s1 = format!("dummy:{}", head.uri);
//netpod::log::info!("try to parse {}", s1);
info!("try to parse {:?}", s1);
let url = Url::parse(&s1)?;
let query = ChannelSearchQuery::from_url(&url)?;
//let query = ChannelSearchQuery::from_query_string(head.uri.query())?;
info!("search query: {:?}", 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)?;