package org.academiadecodigo.enuminatti.helloworldspringmvc.controller;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

/**
 * MIT License
 * (c) 2017 Ricardo Constantino
 */

@Controller
@RequestMapping("/hello")
public class HelloController {

    @RequestMapping(method = RequestMethod.GET, value = "/{word}")
    public String sayHello(@PathVariable String word, Model model) {

        model.addAttribute("greeting", "Hello " + word);

        return "index";
    }

    @RequestMapping(method = RequestMethod.GET, value = "/")
    public String sayHello(Model model) {

        model.addAttribute("greeting", "Hello there");

        return "index";
    }

}
