Struct hyper_staticfile::Static
[−]
[src]
pub struct Static<U = DefaultUpstream> { /* fields omitted */ }
A Hyper service implementing static file serving.
This service serves files from a single filesystem path, which may be absolute or relative.
Incoming requests are mapped onto the filesystem by appending their URL path to the service
root path. If the filesystem path corresponds to a regular file, the service will attempt to
serve it. Otherwise, if the path corresponds to a directory containing an index.html
,
the service will attempt to serve that instead.
If the path doesn't match any real object in the filesystem, the service will call the optional upstream service, or respond with 404. Permission errors always result in a 403 response.
Only GET
and HEAD
requests are handled. Requests with a different method are passed to
the optional upstream service, or responded to with 400.
If an IO error occurs whilst attempting to serve a file, hyper::Error(Io)
will be returned.
Methods
impl<U> Static<U>
[src]
fn with_upstream<P: Into<PathBuf>>(
handle: &Handle,
root: P,
upstream: U
) -> Self
handle: &Handle,
root: P,
upstream: U
) -> Self
Create a new instance of Static
with a given root path and upstream.
If Path::new("")
is given, files will be served from the current directory.
fn with_cache_headers(self, seconds: u32) -> Self
Add cache headers to responses for the given duration.
impl Static<DefaultUpstream>
[src]
fn new<P: Into<PathBuf>>(handle: &Handle, root: P) -> Self
Create a new instance of Static
with a given root path.
If Path::new("")
is given, files will be served from the current directory.
Trait Implementations
impl<U: Clone> Clone for Static<U>
[src]
fn clone(&self) -> Static<U>
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0
Performs copy-assignment from source
. Read more
impl<U> Service for Static<U> where
U: Service<Request = Request, Response = Response, Error = Error, Future = Box<Future<Item = Response, Error = Error>>>,
[src]
U: Service<Request = Request, Response = Response, Error = Error, Future = Box<Future<Item = Response, Error = Error>>>,
type Request = Request
Requests handled by the service.
type Response = Response
Responses given by the service.
type Error = Error
Errors produced by the service.
type Future = Box<Future<Item = Response, Error = Error>>
The future response value.
fn call(&self, req: Request) -> Self::Future
Process the request and return the response asynchronously.