pub struct ServeFile { /* private fields */ }Expand description
Static file server for serving individual files.
Implementations§
Source§impl ServeFile
impl ServeFile
Sourcepub fn builder<P>(path: P) -> ServeFileBuilder
pub fn builder<P>(path: P) -> ServeFileBuilder
Creates a new builder for configuring a ServeFile.
Sourcepub async fn handle(&self, _req: Request<TakoBody>) -> impl Responder
pub async fn handle(&self, _req: Request<TakoBody>) -> impl Responder
Handles an HTTP request to serve the configured static file.
The request itself is ignored — ServeFile always serves the file
configured on the builder, regardless of req.uri(). Mount this
handler on a single specific route (e.g. /manifest.json), not on a
catch-all glob, otherwise every URL under that glob will return the
same file. Use ServeDir when you want path-aware static serving.
Auto Trait Implementations§
impl Freeze for ServeFile
impl RefUnwindSafe for ServeFile
impl Send for ServeFile
impl Sync for ServeFile
impl Unpin for ServeFile
impl UnsafeUnpin for ServeFile
impl UnwindSafe for ServeFile
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more