Skip to content

Commit

Permalink
Add healthcheck endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
mwithi committed Dec 17, 2024
1 parent 8edeb4d commit 9e3afb3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
3 changes: 2 additions & 1 deletion src/main/java/org/isf/config/SecurityConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,8 @@ public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
.cors(cors -> cors.configurationSource(corsConfigurationSource()))
.csrf(csrf -> csrf.disable()) // Disable CSRF protection
.authorizeHttpRequests(auth -> auth
.requestMatchers("/", "/auth/login", "/auth/refresh-token").permitAll()
.requestMatchers("/", "/healthcheck").permitAll()
.requestMatchers("/auth/login", "/auth/refresh-token").permitAll()
.requestMatchers("/swagger-ui/**", "/v3/api-docs/**", "/v3/api-docs.yaml").permitAll()
// admissions
.requestMatchers(HttpMethod.POST, "/admissions/**").hasAuthority("admissions.create")
Expand Down
17 changes: 12 additions & 5 deletions src/main/java/org/isf/menu/rest/RootController.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,28 @@
import java.util.Map;

import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/")
@RequestMapping(produces = MediaType.APPLICATION_JSON_VALUE)
public class RootController {

@GetMapping(produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String, String>> root() {
@GetMapping(value = "/")
public Map<String, String> root() {
Map<String, String> response = new LinkedHashMap<>();
response.put("service", "Open Hospital API");
response.put("version", "0.1.0");
response.put("documentation", "/swagger-ui/index.html");
return ResponseEntity.ok(response);
response.put("healthcheck", "/healthcheck");
return response;
}

@GetMapping(value = "/healthcheck")
public Map<String, String> healthcheck() {
Map<String, String> response = new LinkedHashMap<>();
response.put("status", "UP");
return response;
}
}

0 comments on commit 9e3afb3

Please sign in to comment.