From 986198ab8fd883395d04fb347507cc7f8ca4e449 Mon Sep 17 00:00:00 2001 From: Janis Goldschmidt Date: Mon, 22 Feb 2021 11:50:28 +0100 Subject: [PATCH] Implement getters for named file fields --- actix-files/src/named.rs | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/actix-files/src/named.rs b/actix-files/src/named.rs index a688b2e6c..697651bb4 100644 --- a/actix-files/src/named.rs +++ b/actix-files/src/named.rs @@ -171,6 +171,42 @@ impl NamedFile { self.path.as_path() } + /// Retrieve the time the file was modified. + #[inline] + pub fn modified(&self) -> Option<&SystemTime> { + self.modified.as_ref() + } + + /// Retrieve the metadata associated with this file. + #[inline] + pub fn md(&self) -> &Metadata { + &self.md + } + + /// Retrieve the value of the `ContentType` header for serving this file. + #[inline] + pub fn content_type(&self) -> &mime::Mime { + &self.content_type + } + + /// Retrieve the value of the `ContentDisposition` header for serving this file. + #[inline] + pub fn content_disposition(&self) -> &header::ContentDisposition { + &self.content_disposition + } + + /// Retrieve the content encoding for serving this file. + #[inline] + pub fn encoding(&self) -> Option<&ContentEncoding> { + self.encoding.as_ref() + } + + /// Retrieve the status code for serving this file. + #[inline] + pub fn status_code(&self) -> &StatusCode { + &self.status_code + } + /// Set response **Status Code** pub fn set_status_code(mut self, status: StatusCode) -> Self { self.status_code = status;