mirror of
https://github.com/GreptimeTeam/greptimedb.git
synced 2026-01-08 14:22:58 +00:00
feat: introduce /v1/health for healthcheck from external (#6388)
Signed-off-by: Ning Sun <sunning@greptime.com>
This commit is contained in:
@@ -117,7 +117,7 @@ const DEFAULT_BODY_LIMIT: ReadableSize = ReadableSize::mb(64);
|
||||
pub const AUTHORIZATION_HEADER: &str = "x-greptime-auth";
|
||||
|
||||
// TODO(fys): This is a temporary workaround, it will be improved later
|
||||
pub static PUBLIC_APIS: [&str; 2] = ["/v1/influxdb/ping", "/v1/influxdb/health"];
|
||||
pub static PUBLIC_APIS: [&str; 3] = ["/v1/influxdb/ping", "/v1/influxdb/health", "/v1/health"];
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct HttpServer {
|
||||
@@ -723,6 +723,10 @@ impl HttpServer {
|
||||
"/health",
|
||||
routing::get(handler::health).post(handler::health),
|
||||
)
|
||||
.route(
|
||||
&format!("/{HTTP_API_VERSION}/health"),
|
||||
routing::get(handler::health).post(handler::health),
|
||||
)
|
||||
.route(
|
||||
"/ready",
|
||||
routing::get(handler::health).post(handler::health),
|
||||
@@ -1299,6 +1303,16 @@ mod test {
|
||||
"*"
|
||||
);
|
||||
|
||||
let res = client.get("/v1/health").send().await;
|
||||
|
||||
assert_eq!(res.status(), StatusCode::OK);
|
||||
assert_eq!(
|
||||
res.headers()
|
||||
.get(http::header::ACCESS_CONTROL_ALLOW_ORIGIN)
|
||||
.expect("expect cors header origin"),
|
||||
"*"
|
||||
);
|
||||
|
||||
let res = client
|
||||
.options("/health")
|
||||
.header("Access-Control-Request-Headers", "x-greptime-auth")
|
||||
|
||||
Reference in New Issue
Block a user