|
@@ -0,0 +1,21 @@
|
|
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
|
+ private final AtomicLong counter = new AtomicLong();
|
|
13
|
+ private static final String template = "Hello, %s!";
|
|
14
|
+ @RequestMapping("/greeting")
|
|
15
|
+ public main.java.hello.Greeting greeting(@RequestParam(value="name", defaultValue="World") String name) {
|
|
16
|
+
|
|
17
|
+ return new main.java.hello.Greeting(counter.incrementAndGet(),
|
|
18
|
+ String.format(template, name));
|
|
19
|
+
|
|
20
|
+ }
|
|
21
|
+}
|