Repository: camel
Updated Branches:
  refs/heads/master 5fa7a8a4b -> 19fa67a64


Polish example

Signed-off-by: Gregor Zurowski <gre...@zurowski.org>


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/19fa67a6
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/19fa67a6
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/19fa67a6

Branch: refs/heads/master
Commit: 19fa67a64410d90b428998d33598891094567aad
Parents: 1612ede
Author: Gregor Zurowski <gre...@zurowski.org>
Authored: Wed Apr 12 11:24:24 2017 +0200
Committer: Gregor Zurowski <gre...@zurowski.org>
Committed: Wed Apr 12 11:26:07 2017 +0200

----------------------------------------------------------------------
 .../src/main/java/sample/camel/PetController.java     | 14 ++++++++------
 .../src/main/java/sample/camel/RestRoute.java         |  2 +-
 2 files changed, 9 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/19fa67a6/examples/camel-example-rest-producer/src/main/java/sample/camel/PetController.java
----------------------------------------------------------------------
diff --git 
a/examples/camel-example-rest-producer/src/main/java/sample/camel/PetController.java
 
b/examples/camel-example-rest-producer/src/main/java/sample/camel/PetController.java
index d9bb346..71c1802 100644
--- 
a/examples/camel-example-rest-producer/src/main/java/sample/camel/PetController.java
+++ 
b/examples/camel-example-rest-producer/src/main/java/sample/camel/PetController.java
@@ -16,8 +16,11 @@
  */
 package sample.camel;
 
+import java.util.Collections;
+import java.util.Map;
+
+import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
 /**
@@ -28,15 +31,14 @@ public class PetController {
 
     private static final String[] PETS = new String[]{"Snoopy", "Fido", "Tony 
the Tiger"};
 
-    @RequestMapping(value = "/petById/{id}", produces = "application/json")
-    public String petById(@PathVariable("id") Integer id) {
+    @GetMapping(value = "/pets/{id}")
+    public Map<String, String> petById(@PathVariable("id") Integer id) {
         if (id != null && id > 0 && id <= PETS.length + 1) {
             int index = id - 1;
             String pet = PETS[index];
-            return String.format("{ \"name\": \"%s\" }", pet);
+            return Collections.singletonMap("name", pet);
         } else {
-            // empty pet
-            return "{ }";
+            return Collections.emptyMap();
         }
     }
 

http://git-wip-us.apache.org/repos/asf/camel/blob/19fa67a6/examples/camel-example-rest-producer/src/main/java/sample/camel/RestRoute.java
----------------------------------------------------------------------
diff --git 
a/examples/camel-example-rest-producer/src/main/java/sample/camel/RestRoute.java
 
b/examples/camel-example-rest-producer/src/main/java/sample/camel/RestRoute.java
index dc2b2f8..72fb2ea 100644
--- 
a/examples/camel-example-rest-producer/src/main/java/sample/camel/RestRoute.java
+++ 
b/examples/camel-example-rest-producer/src/main/java/sample/camel/RestRoute.java
@@ -34,7 +34,7 @@ public class RestRoute extends RouteBuilder {
 
         from("timer:hello?period={{timer.period}}")
             .setHeader("id", simple("${random(1,3)}"))
-            .to("rest:get:petById/{id}")
+            .to("rest:get:pets/{id}")
             .log("${body}");
     }
 

Reply via email to