Add support for content type
This commit is contained in:
parent
50ce8621c2
commit
adbccd8834
3 changed files with 28 additions and 1 deletions
|
@ -209,7 +209,7 @@ impl Controller {
|
||||||
|
|
||||||
let response = Response::builder()
|
let response = Response::builder()
|
||||||
.status(200)
|
.status(200)
|
||||||
//.header("content-type", "application/xml; charset=\"utf-8\"")
|
.header("content-type", self.node.content_type())
|
||||||
.body(boxed_body)?;
|
.body(boxed_body)?;
|
||||||
|
|
||||||
Ok(response)
|
Ok(response)
|
||||||
|
|
|
@ -34,6 +34,8 @@ pub(crate) trait DavNode: Send {
|
||||||
fn properties(&self, user: &ArcUser, prop: dav::PropName<All>) -> Vec<dav::AnyProperty<All>>;
|
fn properties(&self, user: &ArcUser, prop: dav::PropName<All>) -> Vec<dav::AnyProperty<All>>;
|
||||||
/// Put an element (create or update)
|
/// Put an element (create or update)
|
||||||
fn put<'a>(&'a self, policy: PutPolicy, stream: Content<'a>) -> BoxFuture<'a, Result<Etag>>;
|
fn put<'a>(&'a self, policy: PutPolicy, stream: Content<'a>) -> BoxFuture<'a, Result<Etag>>;
|
||||||
|
/// Content type of the element
|
||||||
|
fn content_type(&self) -> &str;
|
||||||
/// Get content
|
/// Get content
|
||||||
fn content<'a>(&'a self) -> BoxFuture<'a, Content<'static>>;
|
fn content<'a>(&'a self) -> BoxFuture<'a, Content<'static>>;
|
||||||
|
|
||||||
|
|
|
@ -70,6 +70,10 @@ impl DavNode for RootNode {
|
||||||
futures::stream::once(futures::future::err(std::io::Error::from(std::io::ErrorKind::Unsupported))).boxed()
|
futures::stream::once(futures::future::err(std::io::Error::from(std::io::ErrorKind::Unsupported))).boxed()
|
||||||
}.boxed()
|
}.boxed()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn content_type(&self) -> &str {
|
||||||
|
"text/plain"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
|
@ -139,6 +143,11 @@ impl DavNode for HomeNode {
|
||||||
futures::stream::once(futures::future::err(std::io::Error::from(std::io::ErrorKind::Unsupported))).boxed()
|
futures::stream::once(futures::future::err(std::io::Error::from(std::io::ErrorKind::Unsupported))).boxed()
|
||||||
}.boxed()
|
}.boxed()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
fn content_type(&self) -> &str {
|
||||||
|
"text/plain"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
|
@ -218,6 +227,10 @@ impl DavNode for CalendarListNode {
|
||||||
futures::stream::once(futures::future::err(std::io::Error::from(std::io::ErrorKind::Unsupported))).boxed()
|
futures::stream::once(futures::future::err(std::io::Error::from(std::io::ErrorKind::Unsupported))).boxed()
|
||||||
}.boxed()
|
}.boxed()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn content_type(&self) -> &str {
|
||||||
|
"text/plain"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
|
@ -314,6 +327,10 @@ impl DavNode for CalendarNode {
|
||||||
futures::stream::once(futures::future::err(std::io::Error::from(std::io::ErrorKind::Unsupported))).boxed()
|
futures::stream::once(futures::future::err(std::io::Error::from(std::io::ErrorKind::Unsupported))).boxed()
|
||||||
}.boxed()
|
}.boxed()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn content_type(&self) -> &str {
|
||||||
|
"text/plain"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const FAKE_ICS: &str = r#"BEGIN:VCALENDAR
|
const FAKE_ICS: &str = r#"BEGIN:VCALENDAR
|
||||||
|
@ -432,6 +449,10 @@ impl DavNode for EventNode {
|
||||||
futures::stream::once(Box::pin(r)).boxed()
|
futures::stream::once(Box::pin(r)).boxed()
|
||||||
}.boxed()
|
}.boxed()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn content_type(&self) -> &str {
|
||||||
|
"text/calendar"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
|
@ -484,4 +505,8 @@ impl DavNode for CreateEventNode {
|
||||||
futures::stream::once(futures::future::err(std::io::Error::from(std::io::ErrorKind::Unsupported))).boxed()
|
futures::stream::once(futures::future::err(std::io::Error::from(std::io::ErrorKind::Unsupported))).boxed()
|
||||||
}.boxed()
|
}.boxed()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn content_type(&self) -> &str {
|
||||||
|
"text/plain"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue