Skip to content

Instantly share code, notes, and snippets.

@milovtim
Last active October 28, 2018 20:27
Show Gist options
  • Save milovtim/d90e4aed64860658479423235e4fac97 to your computer and use it in GitHub Desktop.
Save milovtim/d90e4aed64860658479423235e4fac97 to your computer and use it in GitHub Desktop.
interface DemoInterface {
HelloMsg sayHelloImpl(AddresseeRequest request);
@RequestMapping(value = "/hello")
default HelloMsg sayHello(@RequestBody AddresseeRequest request) {
return sayHelloImpl(request);
}
}
@RestController
public class DemoController implements DemoInterface {
private final String message = "Hello, ";
@Override
public HelloMsg sayHelloImpl(AddresseeRequest request) {
final HelloMsg msg = new HelloMsg();
msg.addressee = request.getName();
msg.message = message + ", " + request.getName();
return msg;
}
}
public class AddresseeRequest {
private String name;
public String getName() { return name; }
public void setName(String name) { this.name = name; }
}
public class HelloMsg {
public String message;
public String addressee;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment