package example.delivery;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.*;
@SpringBootApplication
public class DeliveryApplication {
    public static void main(String[] args) { SpringApplication.run(DeliveryApplication.class,args); }
}
@Service
class GreetingService {
    String greet(String name) {
        if(name==null||name.isBlank()) throw new IllegalArgumentException("name is required");
        return "hello "+name;
    }
}
@RestController
class GreetingController {
    private final GreetingService service;
    GreetingController(GreetingService service) { this.service=service; }
    @GetMapping("/hello") String hello(@RequestParam(defaultValue="reader") String name) {
        return service.greet(name);
    }
}
