Mark response headers optional in media GET endpoints

This commit is contained in:
Jonas Platte 2020-10-11 13:14:04 +02:00
parent 6a1c452ac9
commit f4fc20921a
No known key found for this signature in database
GPG Key ID: 7D261D771D915378
4 changed files with 19 additions and 19 deletions

View File

@ -19,9 +19,8 @@ ruma_api! {
pub filename: Option<&'a str>,
/// The content type of the file being uploaded.
// TODO: This should be optional.
#[ruma_api(header = CONTENT_TYPE)]
pub content_type: &'a str,
pub content_type: Option<&'a str>,
/// The file contents to upload.
#[ruma_api(raw_body)]
@ -37,9 +36,9 @@ ruma_api! {
}
impl<'a> Request<'a> {
/// Creates a new `Request` with the given content type and file contents.
pub fn new(content_type: &'a str, file: Vec<u8>) -> Self {
Self { filename: None, content_type, file }
/// Creates a new `Request` with the given file contents.
pub fn new(file: Vec<u8>) -> Self {
Self { file, filename: None, content_type: None }
}
}

View File

@ -37,11 +37,11 @@ ruma_api! {
/// The content type of the file that was previously uploaded.
#[ruma_api(header = CONTENT_TYPE)]
pub content_type: String,
pub content_type: Option<String>,
/// The name of the file that was previously uploaded, if set.
#[ruma_api(header = CONTENT_DISPOSITION)]
pub content_disposition: String,
pub content_disposition: Option<String>,
}
error: crate::Error
@ -55,8 +55,8 @@ impl<'a> Request<'a> {
}
impl Response {
/// Creates a new `Response` with the given file contents, content type and filename.
pub fn new(file: Vec<u8>, content_type: String, content_disposition: String) -> Self {
Self { file, content_type, content_disposition }
/// Creates a new `Response` with the given file contents.
pub fn new(file: Vec<u8>) -> Self {
Self { file, content_type: None, content_disposition: None }
}
}

View File

@ -41,11 +41,12 @@ ruma_api! {
/// The content type of the file that was previously uploaded.
#[ruma_api(header = CONTENT_TYPE)]
pub content_type: String,
// Potentially not actually optional https://github.com/matrix-org/matrix-doc/pull/2818
pub content_type: Option<String>,
/// The name of the file that was previously uploaded, if set.
#[ruma_api(header = CONTENT_DISPOSITION)]
pub content_disposition: String,
pub content_disposition: Option<String>,
}
error: crate::Error
@ -59,8 +60,8 @@ impl<'a> Request<'a> {
}
impl Response {
/// Creates a new `Response` with the given file, content type and filename.
pub fn new(file: Vec<u8>, content_type: String, content_disposition: String) -> Self {
Self { file, content_type, content_disposition }
/// Creates a new `Response` with the given file.
pub fn new(file: Vec<u8>) -> Self {
Self { file, content_type: None, content_disposition: None }
}
}

View File

@ -61,7 +61,7 @@ ruma_api! {
response: {
/// The content type of the thumbnail.
#[ruma_api(header = CONTENT_TYPE)]
pub content_type: String,
pub content_type: Option<String>,
/// A thumbnail of the requested content.
#[ruma_api(raw_body)]
@ -80,8 +80,8 @@ impl<'a> Request<'a> {
}
impl Response {
/// Creates a new `Response` with the given content type and thumbnail.
pub fn new(content_type: String, file: Vec<u8>) -> Self {
Self { content_type, file }
/// Creates a new `Response` with the given thumbnail.
pub fn new(file: Vec<u8>) -> Self {
Self { file, content_type: None }
}
}