From 42d569c1868a0bce419b9c019bc06023db3db1d5 Mon Sep 17 00:00:00 2001 From: Dietmar Maurer Date: Tue, 6 Nov 2018 09:35:11 +0100 Subject: [PATCH] move url related code back to main.rs --- src/json_schema.rs | 9 --------- src/main.rs | 5 ++++- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/json_schema.rs b/src/json_schema.rs index 737b5805..69d59dfa 100644 --- a/src/json_schema.rs +++ b/src/json_schema.rs @@ -1,6 +1,5 @@ use failure::*; use std::collections::HashMap; -use url::form_urlencoded; use serde_json::{json, Value}; pub type PropertyMap = HashMap<&'static str, Jss>; @@ -126,14 +125,6 @@ pub fn parse_parameter_strings(data: &Vec<(String, String)>, schema: &Jss) -> Re Ok(json!(null)) } -pub fn parse_query(query: &str, schema: &Jss) -> Result { - - let raw_param: Vec<(String, String)> = - form_urlencoded::parse(query.as_bytes()).into_owned().collect(); - - parse_parameter_strings(&raw_param, schema) -} - #[test] fn test_shema1() { let schema = Jss::Object(JssObject { diff --git a/src/main.rs b/src/main.rs index f2261366..6213f357 100644 --- a/src/main.rs +++ b/src/main.rs @@ -65,7 +65,10 @@ fn handle_request(req: Request) -> Response { // extract param let param = match query { Some(data) => { - match parse_query(data, &api_method.parameters) { + let param_list: Vec<(String, String)> = + form_urlencoded::parse(data.as_bytes()).into_owned().collect(); + + match parse_parameter_strings(¶m_list, &api_method.parameters) { Ok(query) => query, Err(err) => http_error!(NOT_FOUND, format!("Unable to parse query parameters '{}' - {}", data, err)), }