From a5c0cfb12b1a1c8987c961265e0102da9183abfe Mon Sep 17 00:00:00 2001 From: Lucien Greathouse Date: Thu, 12 Apr 2018 22:17:41 -0700 Subject: [PATCH] Clean up web utilities --- server/src/web.rs | 4 ++-- server/src/web_util.rs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/server/src/web.rs b/server/src/web.rs index 93684cde..850be31e 100644 --- a/server/src/web.rs +++ b/server/src/web.rs @@ -3,7 +3,7 @@ use std::time::Instant; use rouille; use project::Project; -use web_util::json; +use web_util::json_response; /// The set of configuration the web server needs to start. pub struct WebConfig { @@ -39,7 +39,7 @@ pub fn start(config: WebConfig, project: Project, start_time: Instant) { elapsed.as_secs() as f64 + elapsed.subsec_nanos() as f64 / 1_000_000_000.0 }; - json(ServerInfo { + json_response(ServerInfo { server_version: env!("CARGO_PKG_VERSION"), protocol_version: 1, server_id: &server_id, diff --git a/server/src/web_util.rs b/server/src/web_util.rs index 7feacaa1..8bb3140f 100644 --- a/server/src/web_util.rs +++ b/server/src/web_util.rs @@ -6,7 +6,7 @@ use serde_json; static MAX_BODY_SIZE: usize = 25 * 1024 * 1024; // 25 MiB -pub fn json(value: T) -> rouille::Response { +pub fn json_response(value: T) -> rouille::Response { let data = serde_json::to_string(&value).unwrap(); rouille::Response::from_data("application/json", data) } @@ -15,7 +15,7 @@ pub fn json(value: T) -> rouille::Response { /// /// Doesn't do any actual parsing -- all this method does is verify the content /// type of the request and read the request's body. -pub fn read_json_text(request: &rouille::Request) -> Option { +fn read_json_text(request: &rouille::Request) -> Option { // Bail out if the request body isn't marked as JSON match request.header("Content-Type") { Some(header) => if !header.starts_with("application/json") {