Server side is added
This commit is contained in:
12
Server/src/main/java/hello/Application.java
Normal file
12
Server/src/main/java/hello/Application.java
Normal file
@@ -0,0 +1,12 @@
|
||||
package hello;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
@SpringBootApplication
|
||||
public class Application {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(Application.class, args);
|
||||
}
|
||||
}
|
||||
20
Server/src/main/java/hello/Greeting.java
Normal file
20
Server/src/main/java/hello/Greeting.java
Normal file
@@ -0,0 +1,20 @@
|
||||
package hello;
|
||||
|
||||
public class Greeting {
|
||||
|
||||
private final long id;
|
||||
private final String content;
|
||||
|
||||
public Greeting(long id, String content) {
|
||||
this.id = id;
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public String getContent() {
|
||||
return content;
|
||||
}
|
||||
}
|
||||
19
Server/src/main/java/hello/GreetingController.java
Normal file
19
Server/src/main/java/hello/GreetingController.java
Normal file
@@ -0,0 +1,19 @@
|
||||
package hello;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
public class GreetingController {
|
||||
|
||||
private static final String template = "Hello, %s!";
|
||||
private final AtomicLong counter = new AtomicLong();
|
||||
|
||||
@RequestMapping("/greeting")
|
||||
public Greeting greeting(@RequestParam(value="name", defaultValue="World") String name) {
|
||||
return new Greeting(counter.incrementAndGet(),
|
||||
String.format(template, name));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user