001package io.jstach.opt.spring.example.message;
002
003import org.springframework.stereotype.Controller;
004import org.springframework.web.bind.annotation.GetMapping;
005import org.springframework.web.servlet.View;
006
007import io.jstach.opt.spring.webmvc.JStachioModelView;
008
009/**
010 * Example controller that uses a View which has global state injected into it via a
011 * handler interceptor.
012 *
013 * @author dsyer
014 */
015@SuppressWarnings("exports")
016@Controller
017public class MessageController {
018
019        /**
020         * Created by Spring
021         */
022        public MessageController() {
023        }
024
025        /**
026         * Here we use the global configurer to inject state into the {@link View}.
027         * @return view
028         */
029        @GetMapping(value = "/message")
030        public View message() {
031                return JStachioModelView.of(new MessagePage());
032        }
033
034        /**
035         * Here we use the return value type to construct a {@link View} that will be
036         * rendered.
037         * @return the jstache model that will be rendered
038         */
039        @GetMapping(value = "/msg")
040        public MessagePage msg() {
041                return new MessagePage();
042        }
043
044}