简体   繁体   English

将 header 传递给自定义执行器健康端点

[英]Passing a header to custom actuator health endpoint

I have created a custom spring-boot actuator health endpoint for my application.我为我的应用程序创建了一个自定义 spring-boot 执行器健康端点。 Spring boot aggregates all these custom health endpoints into a one big json and returns it when I hit application/health url. Spring 引导将所有这些自定义健康端点聚合到一个大的 json 并在我点击应用程序/健康url 时返回它。 Now I want to pass some information to the custom health end point that I have implemented in form of a header when I hit the application/health url.现在,当我点击应用程序/健康url 时,我想将一些信息传递给我以 header 的形式实现的自定义健康端点。 How can I achieve this?我怎样才能做到这一点?

If you at all want to pass a header, you might consider hitting the API (a GET API in this case) from any RestClient like PostMan or Insomnia. If you at all want to pass a header, you might consider hitting the API (a GET API in this case) from any RestClient like PostMan or Insomnia. Simply hitting the url from the browser is actually making a GET request but you can only add path or request parameters in the url, for adding a request body or headers,you will need to use a REST client, or alternatively do it from the command line using curl.只需从浏览器中点击 url 实际上是在发出 GET 请求,但您只能在 url 中添加路径或请求参数,要添加请求正文或标头,您将需要使用来自客户端的 Z50780F47F47F6839D43FZ0 或 47F6839D47D60 命令线使用 curl。 Also, after reading the comments,i think what you need is,is to set spring.profile property and determine your code flow based on that- here's how you can set the profile- 1) set Java System Properties (VM Arguments)另外,在阅读了评论之后,我认为您需要的是设置 spring.profile 属性并根据该属性确定您的代码流-这是设置配置文件的方法- 1)设置 Java 系统属性(VM参数)

java -jar -Dspring.profiles.active=test myapp.jar

2) set Program arguments 2)设置程序arguments

java -jar application.jar --spring.profiles.active=test 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Spring Boot Actuator - 自定义健康端点 - Spring Boot Actuator - Custom Health Endpoint 如何在Spring Boot执行器中实现自定义终结点以保持健康 - How to implement custom endpoint in Spring Boot actuator to health Java Spring 启动 - 将执行器健康端点的端口更改为自定义端口 - Java Spring Boot - Change the Port of Actuator Health Endpoint to a Custom Port 自定义健康执行器属性 - Custom health actuator properties 获取执行器/运行状况端点的状态代码为“DOWN” - getting status code as "DOWN" for actuator/health endpoint Consul Health 指标未显示在 SpringBoot 的执行器健康端点中 - Consul Health indicator not showing in SpringBoot' actuator health endpoint Spring Boot Actuator:缓存 /actuator/health/readiness 和 /actuator/health/custom 健康检查结果 - Spring Boot Actuator: Caching /actuator/health/readiness and /actuator/health/custom health check results 不显示Spring Boot Actuator / health端点的磁盘空间和数据库 - Do not show diskspace and db for Spring Boot Actuator /health endpoint 升级到 Boot 1.2 后无法访问 Spring Boot 执行器运行状况端点 - Spring Boot actuator health endpoint not accessible after upgrading to Boot 1.2 试图保护执行器健康端点给出 403 禁止错误 - Trying to secure actuator health endpoint giving 403 Forbidden error
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM