From b83d7bb032db2f8c7f584aa8595ea174641c91a3 Mon Sep 17 00:00:00 2001 From: Christiane Ruetten Date: Mon, 29 Feb 2016 15:01:40 +0100 Subject: [PATCH] Switching to `json!` macro --- src/controller.rs | 3 +-- src/service_router.rs | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/controller.rs b/src/controller.rs index 4198d53e..754a69b5 100644 --- a/src/controller.rs +++ b/src/controller.rs @@ -93,8 +93,7 @@ impl Controller for FoxBox { let services = self.services.lock().unwrap(); match services.get(&id) { None => { - let mut response = Response::with(format!( - "{{\"result\": \"error\", \"details\": \"No Such Service: {}\"}}", id)); + let mut response = Response::with(json!({ error: "NoSuchService", id: id })); response.status = Some(Status::BadRequest); response.headers.set(AccessControlAllowOrigin::Any); response.headers.set(ContentType::json()); diff --git a/src/service_router.rs b/src/service_router.rs index b1ba6a82..12220106 100644 --- a/src/service_router.rs +++ b/src/service_router.rs @@ -149,8 +149,7 @@ describe! service_router { &service_router).unwrap(); let result = response::extract_body_to_string(response); - assert_eq!(result, - "{\"result\": \"error\", \"details\": \"No Such Service: unknown-id\"}"); + assert_eq!(result, "{\"error\":\"NoSuchService\",\"id\":\"unknown-id\"}"); } it "should get the appropriate CORS headers" {