rust - 为什么 rust 火箭健康显示 404 未找到
问题描述
我在 rust Rocket 中实现健康检查 api,如下所示:
rocket_healthz::healthz!();
#[launch]
fn rocket() -> _ {
rocket::build()
.mount("/actuator/health", routes![healthz])
}
但是当我使用这个命令访问健康 API 时:
curl http://127.0.0.1:11014/actuator/health
显示结果如下:
root@dolphin-music-service-6768d8497f-fwvjj:/app# curl http://127.0.0.1:11014/actuator/health
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>404 Not Found</title>
</head>
<body align="center">
<div role="main" align="center">
<h1>404: Not Found</h1>
<p>The requested resource could not be found.</p>
<hr />
</div>
<div role="contentinfo" align="center">
<small>Rocket</small>
</div>
</body>
我在哪里做错了?我应该怎么做才能解决这个问题?顺便说一句,这是火箭健康货物依赖:
rocket_healthz = "0.2.0"
解决方案
从文档中,它看起来像是添加了/healthz
部件本身。如所写,调用端点/actuator/health/healthz
应该可以工作。
如果您愿意,我看不到您可以自定义路线/health
而不是/healthz
.
推荐阅读
- ruby-on-rails - 如何编写rails活动记录回调类after_create_commit
- c - 给函数一个结构指针时的段错误
- javascript - 用于角度电子邮件验证的正则表达式
- node.js - 在 MEAN 堆栈应用程序中实现搜索
- javascript - 为什么这个模板文字在反应原生图像源中不起作用?
- tensorflow - 有没有办法在不使用张量流中的转置函数的情况下转置张量?
- mysql - 提取最新的非零收入行
- azure - ADF Tumbling 窗口触发器 - 自依赖
- android - AAB 和 XAPK 有什么区别?
- javascript - 两个物体接触时的A帧触发功能