Skip to content

Commit

Permalink
environment test route added
Browse files Browse the repository at this point in the history
  • Loading branch information
Badri Paudel committed Nov 12, 2024
1 parent 459eea7 commit c0f760c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/main/java/info/keeper/controllers/HomeController.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,13 @@
import info.keeper.repositories.UserRepository;
import info.keeper.utils.Message;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.security.core.Authentication;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.*;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
Expand All @@ -30,6 +28,16 @@ public class HomeController {
@Autowired
private BCryptPasswordEncoder passwordEncoder;

@Autowired
private Environment environment;

@GetMapping("/env")
@ResponseBody
public String getEnv() {
String envPPT = environment.getProperty("app.env.name");
System.out.println("ENV_PPT " + envPPT);
return "Environment => " + envPPT;
}
// displays home page
@GetMapping("/")
public String homePage(Model model) {
Expand Down
4 changes: 4 additions & 0 deletions src/main/resources/application-default.properties
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,7 @@ management.endpoints.web.exposure.include=*
#prometheus
# TODO: implement prometheus later.
management.endpoint.prometheus.enabled=true
#dev is the default value, APP_ENV_NAME can be passed to override.
# can be used to override during runtime as:
# mvn spring-boot:run "-Dspring-boot.run.arguments=--APP_ENV_NAME=prod"
app.env.name=${APP_ENV_NAME:dev}

0 comments on commit c0f760c

Please sign in to comment.