nafis nibir 6 anni fa
parent
commit
f7f4d7e3e7

+ 12
- 0
initial/src/main/java/hello/Application.java Vedi File

@@ -0,0 +1,12 @@
1
+package hello;
2
+
3
+import org.springframework.boot.SpringApplication;
4
+import org.springframework.boot.autoconfigure.SpringBootApplication;
5
+
6
+@SpringBootApplication
7
+public class Application {
8
+
9
+    public static void main(String[] args) {
10
+        SpringApplication.run(Application.class, args);
11
+    }
12
+}

+ 19
- 0
initial/src/main/java/hello/Greeting.java Vedi File

@@ -0,0 +1,19 @@
1
+package hello;
2
+
3
+public class Greeting {
4
+    private final long id;
5
+    private final String content;
6
+
7
+    public Greeting(long id, String content) {
8
+        this.id = id;
9
+        this.content = content;
10
+    }
11
+
12
+    public long getId() {
13
+        return id;
14
+    }
15
+
16
+    public String getContent() {
17
+        return content;
18
+    }
19
+}

+ 17
- 0
initial/src/main/java/hello/GreetingController.java Vedi File

@@ -0,0 +1,17 @@
1
+package hello;
2
+import java.util.concurrent.atomic.AtomicLong;
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
+@RestController
8
+public class GreetingController {
9
+    private static final String template = "Hello, %s!";
10
+    private final AtomicLong counter = new AtomicLong();
11
+
12
+    @RequestMapping("/greeting")
13
+    public Greeting greeting(@RequestParam(value="name", defaultValue="World") String name) {
14
+        return new Greeting(counter.incrementAndGet(),
15
+                String.format(template, name));
16
+    }
17
+}