PUT object: Return ETag

This commit is contained in:
Lennart
2025-12-31 16:17:34 +01:00
parent 4fabf74333
commit 271fdfd686
3 changed files with 21 additions and 8 deletions

View File

@@ -7,6 +7,7 @@ use axum::extract::{Path, State};
use axum::response::{IntoResponse, Response};
use axum_extra::TypedHeader;
use axum_extra::headers::{ContentType, ETag, HeaderMapExt, IfNoneMatch};
use http::HeaderValue;
use http::Method;
use http::{HeaderMap, StatusCode};
use rustical_dav::privileges::UserPrivilege;
@@ -87,9 +88,15 @@ pub async fn put_object<AS: AddressbookStore>(
};
let object = AddressObject::from_vcf(object_id, body)?;
let etag = object.get_etag();
addr_store
.put_object(principal, addressbook_id, object, overwrite)
.await?;
Ok(StatusCode::CREATED.into_response())
let mut headers = HeaderMap::new();
headers.insert(
"ETag",
HeaderValue::from_str(&etag).expect("Contains no invalid characters"),
);
Ok((StatusCode::CREATED, headers).into_response())
}