From 0a3e775c1a2b7f8b65d845642f27f46cd32ac43d Mon Sep 17 00:00:00 2001 From: Pekka Helenius Date: Mon, 12 Oct 2020 23:30:28 +0300 Subject: [PATCH] Implement a controller for development end points Signed-off-by: Pekka Helenius --- .../bookstore/web/BookDevController.java | 51 +++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 bookstore/src/main/java/com/fjordtek/bookstore/web/BookDevController.java diff --git a/bookstore/src/main/java/com/fjordtek/bookstore/web/BookDevController.java b/bookstore/src/main/java/com/fjordtek/bookstore/web/BookDevController.java new file mode 100644 index 0000000..1cdcc04 --- /dev/null +++ b/bookstore/src/main/java/com/fjordtek/bookstore/web/BookDevController.java @@ -0,0 +1,51 @@ +//Pekka Helenius , Fjordtek 2020 + +package com.fjordtek.bookstore.web; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Profile; +import org.springframework.core.env.Environment; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; + +import com.fjordtek.bookstore.service.HttpServerLogger; + +/** + * + * This class implements a Spring Model View controller for bookstore development + * end points. + * + * @author Pekka Helenius + */ + +@Controller +@RequestMapping("${page.url.dev}") +@Profile("dev") +public class BookDevController { + + @Autowired + private Environment env; + + @Autowired + private HttpServerLogger httpServerLogger; + + ////////////////////////////// + // SPRING ACTUATOR HELP PAGE + @RequestMapping( + value = "${page.url.dev.statsref}", + method = { RequestMethod.GET } + ) + public String webFormActuatorRef( + HttpServletRequest requestData, + HttpServletResponse responseData + ) { + httpServerLogger.log(requestData, responseData); + return env.getProperty("page.url.dev.statsref"); + } + +} +