Change /read to use a list of IDs instead of POSTing JSON

This commit is contained in:
Lucien Greathouse 2018-06-05 23:43:10 -07:00
parent c85e5c8a78
commit 565bed2b9d

View file

@ -10,7 +10,6 @@ use project::Project;
use rbx::RbxInstance; use rbx::RbxInstance;
use rbx_session::RbxSession; use rbx_session::RbxSession;
use session::Session; use session::Session;
use web_util::read_json;
/// The set of configuration the web server needs to start. /// The set of configuration the web server needs to start.
pub struct WebConfig { pub struct WebConfig {
@ -168,10 +167,15 @@ impl Server {
}) })
}, },
(POST) (/api/read) => { (GET) (/api/read/{ id_list: String }) => {
let requested_ids = match read_json::<Vec<Id>>(request) { let requested_ids = id_list
Some(body) => body, .split(",")
None => return rouille::Response::text("Malformed JSON").with_status_code(400), .map(str::parse::<Id>)
.collect::<Result<Vec<Id>, _>>();
let requested_ids = match requested_ids {
Ok(v) => v,
Err(_) => return rouille::Response::text("Malformed ID list").with_status_code(400),
}; };
let rbx_session = self.config.rbx_session.read().unwrap(); let rbx_session = self.config.rbx_session.read().unwrap();