package dev.elaine.springlab.web;

import dev.elaine.springlab.domain.GreetingService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
public final class GreetingController {
    private final GreetingService greetingService;

    public GreetingController(GreetingService greetingService) {
        this.greetingService = greetingService;
    }

    @GetMapping("/greetings")
    public Map<String, String> greet(@RequestParam String name) {
        return Map.of("message", greetingService.greet(name));
    }
}

