Skip to content

Commit

Permalink
Switching to json! macro
Browse files Browse the repository at this point in the history
  • Loading branch information
Christiane Ruetten committed Mar 1, 2016
1 parent f982f0d commit b83d7bb
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
3 changes: 1 addition & 2 deletions src/controller.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
3 changes: 1 addition & 2 deletions src/service_router.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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" {
Expand Down

0 comments on commit b83d7bb

Please sign in to comment.