首页 > 解决方案 > 为什么 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"

标签: rust

解决方案


文档中,它看起来像是添加了/healthz部件本身。如所写,调用端点/actuator/health/healthz应该可以工作。

如果您愿意,我看不到您可以自定义路线/health而不是/healthz.


推荐阅读