Struct hyper_staticfile::util::FileResponseBuilder
source · pub struct FileResponseBuilder {
pub cache_headers: Option<u32>,
pub is_head: bool,
pub if_modified_since: Option<SystemTime>,
pub range: Option<String>,
pub if_range: Option<String>,
}
Expand description
Utility to build responses for serving a file.
This struct allows direct access to its fields, but these fields are typically initialized by the accessors, using the builder pattern. The fields are basically a bunch of settings that determine the response details.
Fields§
§cache_headers: Option<u32>
Whether to send cache headers, and what lifespan to indicate.
is_head: bool
Whether this is a HEAD
request, with no response body.
if_modified_since: Option<SystemTime>
The parsed value of the If-Modified-Since
request header.
range: Option<String>
The file ranges to read, if any, otherwise we read from the beginning.
if_range: Option<String>
The unparsed value of the If-Range
request header. May match etag or last-modified.
Implementations§
source§impl FileResponseBuilder
impl FileResponseBuilder
sourcepub fn request<B>(&mut self, req: &Request<B>) -> &mut Self
pub fn request<B>(&mut self, req: &Request<B>) -> &mut Self
Apply parameters based on a request.
sourcepub fn request_parts(
&mut self,
method: &Method,
headers: &HeaderMap
) -> &mut Self
pub fn request_parts( &mut self, method: &Method, headers: &HeaderMap ) -> &mut Self
Apply parameters based on request parts.
sourcepub fn request_method(&mut self, method: &Method) -> &mut Self
pub fn request_method(&mut self, method: &Method) -> &mut Self
Apply parameters based on a request method.
sourcepub fn request_headers(&mut self, headers: &HeaderMap) -> &mut Self
pub fn request_headers(&mut self, headers: &HeaderMap) -> &mut Self
Apply parameters based on request headers.
sourcepub fn cache_headers(&mut self, value: Option<u32>) -> &mut Self
pub fn cache_headers(&mut self, value: Option<u32>) -> &mut Self
Add cache headers to responses for the given lifespan.
sourcepub fn is_head(&mut self, value: bool) -> &mut Self
pub fn is_head(&mut self, value: bool) -> &mut Self
Set whether this is a HEAD
request, with no response body.
sourcepub fn if_modified_since(&mut self, value: Option<SystemTime>) -> &mut Self
pub fn if_modified_since(&mut self, value: Option<SystemTime>) -> &mut Self
Build responses for the given If-Modified-Since
date-time.
sourcepub fn if_modified_since_header(
&mut self,
value: Option<&HeaderValue>
) -> &mut Self
pub fn if_modified_since_header( &mut self, value: Option<&HeaderValue> ) -> &mut Self
Build responses for the given If-Modified-Since
request header value.
sourcepub fn if_range(&mut self, value: Option<&HeaderValue>) -> &mut Self
pub fn if_range(&mut self, value: Option<&HeaderValue>) -> &mut Self
Build responses for the given If-Range
request header value.
sourcepub fn range_header(&mut self, value: Option<&HeaderValue>) -> &mut Self
pub fn range_header(&mut self, value: Option<&HeaderValue>) -> &mut Self
Build responses for the given Range
request header value.
sourcepub fn build<F: IntoFileAccess>(
&self,
file: ResolvedFile<F>
) -> Result<Response<Body<F::Output>>>
pub fn build<F: IntoFileAccess>( &self, file: ResolvedFile<F> ) -> Result<Response<Body<F::Output>>>
Build a response for the given resolved file.
Trait Implementations§
source§impl Clone for FileResponseBuilder
impl Clone for FileResponseBuilder
source§fn clone(&self) -> FileResponseBuilder
fn clone(&self) -> FileResponseBuilder
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more