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