【问题标题】:Is there a way to pass the request parameter to the /health endpoint?有没有办法将请求参数传递给 /health 端点?
【发布时间】:2017-03-09 08:36:17
【问题描述】:

我正在编写一个客户健康指标来检查与另一个应用程序的连接。但是要检查这一点,我需要 /health 端点的请求 URL 中的一些请求参数。(例如,我想要的 URL 是“/health?countryCode=IN”) 有没有办法做到这一点? 谢谢。

【问题讨论】:

    标签: spring-boot spring-boot-actuator


    【解决方案1】:

    获取HttpServletRequest 对象注入如下:

    public class CustomHealthIndicator{
        
        @Autowired
        HttpServletRequest request;
    
    }
    

    获取参数:

    request.getParameter("countryCode")
    

    【讨论】:

    • 顺便提一下错字,是org.springframework.beans.factory.annotation.Autowired
    猜你喜欢
    • 2016-02-06
    • 1970-01-01
    • 1970-01-01
    • 2012-02-25
    • 1970-01-01
    • 2022-01-03
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多