oparl-service/oparl-server/src/main/java/de/twomartens/oparlservice/control/GreetingController.java

25 lines
818 B
Java

package de.twomartens.oparlservice.control;
import de.twomartens.oparlservice.entity.Greeting;
import de.twomartens.oparlservice.service.GreetingService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class GreetingController {
private final GreetingService service;
GreetingController(GreetingService service) {
this.service = service;
}
@GetMapping("/greeting")
@ResponseBody
public Greeting greeting(@RequestParam(value = "name", defaultValue = "World") String name) {
return Greeting.builder().message(service.createGreeting(name)).build();
}
}