refactor: use `/query` for v1 query API endpoint (#24790)

feat: handle v1 query API at /query and update tests
pull/24798/head
Trevor Hilton 2024-03-20 08:26:28 -04:00 committed by GitHub
parent 1fe414c14b
commit 84b85a9b1c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 6 additions and 6 deletions

View File

@ -218,8 +218,8 @@ async fn v1_password_parameter() {
.await;
let client = reqwest::Client::new();
let query_url = format!("{base}/api/v1/query", base = server.client_addr());
let write_url = format!("{base}/api/v1/write", base = server.client_addr());
let query_url = format!("{base}/query", base = server.client_addr());
let write_url = format!("{base}/write", base = server.client_addr());
// Send requests without any authentication:
assert_eq!(
client

View File

@ -182,11 +182,11 @@ impl TestServer {
pub async fn api_v1_query(&self, params: &[(&str, &str)]) -> Response {
self.http_client
.get(format!("{base}/api/v1/query", base = self.client_addr(),))
.get(format!("{base}/query", base = self.client_addr(),))
.query(params)
.send()
.await
.expect("send /api/v1/query request to server")
.expect("send /query request to server")
}
}

View File

@ -547,7 +547,7 @@ fn extract_v1_auth_token(req: &mut Request<Body>) -> Option<Vec<u8>> {
req.uri()
.path_and_query()
.and_then(|pq| match pq.path() {
"/api/v1/query" | "/api/v1/write" => pq.query(),
"/query" | "/write" => pq.query(),
_ => None,
})
.map(serde_urlencoded::from_str::<V1AuthParameters>)
@ -805,7 +805,7 @@ where
(Method::GET | Method::POST, "/api/v3/query_influxql") => {
http_server.query_influxql(req).await
}
(Method::GET, "/api/v1/query") => http_server.v1_query(req).await,
(Method::GET, "/query") => http_server.v1_query(req).await,
(Method::GET, "/health" | "/api/v1/health") => http_server.health(),
(Method::GET, "/metrics") => http_server.handle_metrics(),
(Method::GET, "/debug/pprof") => pprof_home(req).await,