|
@@ -0,0 +1,19 @@
|
|
1
|
+package hello;
|
|
2
|
+
|
|
3
|
+import java.util.concurrent.atomic.AtomicLong;
|
|
4
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
5
|
+import org.springframework.web.bind.annotation.RequestParam;
|
|
6
|
+import org.springframework.web.bind.annotation.RestController;
|
|
7
|
+
|
|
8
|
+@RestController
|
|
9
|
+public class GreetingController {
|
|
10
|
+ private static final String template = "Hello, %s!";
|
|
11
|
+ private final AtomicLong counter = new AtomicLong();
|
|
12
|
+
|
|
13
|
+ @RequestMapping("/greeting")
|
|
14
|
+ public Greeting greeting(@RequestParam(value = "name", defaultValue = "World") String name) {
|
|
15
|
+ return new Greeting(counter.incrementAndGet(),
|
|
16
|
+ String.format(template, name));
|
|
17
|
+ }
|
|
18
|
+}
|
|
19
|
+
|