diff --git a/wfc-auth/src/main/java/org/wfc/auth/controller/TokenController.java b/wfc-auth/src/main/java/org/wfc/auth/controller/TokenController.java index c396a36..8ed932a 100644 --- a/wfc-auth/src/main/java/org/wfc/auth/controller/TokenController.java +++ b/wfc-auth/src/main/java/org/wfc/auth/controller/TokenController.java @@ -2,6 +2,7 @@ package org.wfc.auth.controller; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RestController; @@ -117,4 +118,10 @@ public class TokenController { if ("sys".equals(form.getAuthType())) {} return R.fail("authentication type not supported"); } + + @GetMapping("health") + public R health(HttpServletRequest request) { + // TODO: check health + return R.ok(null,"Auth is healthy"); + } } diff --git a/wfc-gateway/src/main/java/org/wfc/gateway/config/GatewayConfig.java b/wfc-gateway/src/main/java/org/wfc/gateway/config/GatewayConfig.java index 4709860..fc0f028 100644 --- a/wfc-gateway/src/main/java/org/wfc/gateway/config/GatewayConfig.java +++ b/wfc-gateway/src/main/java/org/wfc/gateway/config/GatewayConfig.java @@ -4,7 +4,13 @@ import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.core.Ordered; import org.springframework.core.annotation.Order; +import org.springframework.web.reactive.function.BodyInserters; +import org.springframework.web.reactive.function.server.RouterFunction; +import org.springframework.web.reactive.function.server.RouterFunctions; +import org.springframework.web.reactive.function.server.ServerResponse; import org.wfc.gateway.handler.SentinelFallbackHandler; +import org.springframework.web.reactive.function.server.RequestPredicates; +import org.springframework.http.HttpStatus; /** * 网关限流配置 @@ -20,4 +26,16 @@ public class GatewayConfig { return new SentinelFallbackHandler(); } + + /** + * @return a RouterFunction that handles health check requests + */ + @Bean + public RouterFunction healthCheckRoute() { + // TODO: Implement a health check endpoint + return RouterFunctions.route(RequestPredicates.GET("/health"), + request -> ServerResponse.status(HttpStatus.OK) + .body(BodyInserters.fromValue("Gateway is healthy")) + ); + } } \ No newline at end of file