2
0

feat: auth and gateway support health check api

This commit is contained in:
zhangsz
2024-12-30 09:50:12 +08:00
parent 4ca38eb471
commit b79f2a441a
2 changed files with 25 additions and 0 deletions

View File

@@ -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<ServerResponse> healthCheckRoute() {
// TODO: Implement a health check endpoint
return RouterFunctions.route(RequestPredicates.GET("/health"),
request -> ServerResponse.status(HttpStatus.OK)
.body(BodyInserters.fromValue("Gateway is healthy"))
);
}
}