Add case for no content

This commit is contained in:
Dominik Werder
2025-02-25 11:37:04 +01:00
parent df67384b77
commit 7eae8ed95c
3 changed files with 13 additions and 5 deletions

View File

@@ -1,6 +1,6 @@
[package]
name = "daqbuffer"
version = "0.5.5-aa.8"
version = "0.5.5-aa.9"
authors = ["Dominik Werder <dominik.werder@gmail.com>"]
edition = "2021"

View File

@@ -232,7 +232,7 @@ async fn binned_json_single(
) -> Result<StreamResponse, Error> {
// TODO unify with binned_json_framed
debug!("binned_json_single");
let item = streams::timebinnedjson::timebinned_json(
let res = streams::timebinnedjson::timebinned_json(
res2.query,
res2.ch_conf,
ctx,
@@ -241,7 +241,7 @@ async fn binned_json_single(
res2.timeout_provider,
)
.await?;
match item {
match res {
CollectResult::Some(item) => {
let ret = response(StatusCode::OK)
.header(CONTENT_TYPE, APP_JSON)
@@ -249,10 +249,14 @@ async fn binned_json_single(
.body(ToJsonBody::from(item.into_bytes()).into_body())?;
Ok(ret)
}
CollectResult::Empty => {
let ret = error_status_response(StatusCode::NO_CONTENT, format!("no content"), ctx.reqid());
Ok(ret)
}
CollectResult::Timeout => {
let ret = error_status_response(
StatusCode::GATEWAY_TIMEOUT,
format!("no data within timeout"),
format!("no content within timeout"),
ctx.reqid(),
);
Ok(ret)

View File

@@ -240,10 +240,14 @@ async fn plain_events_json(req: Requ, res2: HandleRes2<'_>) -> Result<StreamResp
debug!("{self_name} response created");
Ok(ret)
}
CollectResult::Empty => {
let ret = error_status_response(StatusCode::NO_CONTENT, format!("no content"), res2.ctx.reqid());
Ok(ret)
}
CollectResult::Timeout => {
let ret = error_status_response(
StatusCode::GATEWAY_TIMEOUT,
format!("no data within timeout"),
format!("no content within timeout"),
res2.ctx.reqid(),
);
Ok(ret)