pub struct ServeServiceBuilder<H> { /* private fields */ }
Expand description
Builder that can be used to run your own serve Service
,
serving a file or directory, or a placeholder page.
Implementations§
Source§impl ServeServiceBuilder<()>
impl ServeServiceBuilder<()>
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a new ServeServiceBuilder
.
Source§impl<H> ServeServiceBuilder<H>
impl<H> ServeServiceBuilder<H>
Sourcepub fn concurrent(self, limit: usize) -> Self
pub fn concurrent(self, limit: usize) -> Self
set the number of concurrent connections to allow
(0 = no limit)
Sourcepub fn set_concurrent(&mut self, limit: usize) -> &mut Self
pub fn set_concurrent(&mut self, limit: usize) -> &mut Self
set the number of concurrent connections to allow
(0 = no limit)
Sourcepub fn body_limit(self, limit: usize) -> Self
pub fn body_limit(self, limit: usize) -> Self
set the body limit in bytes for each request
Sourcepub fn set_body_limit(&mut self, limit: usize) -> &mut Self
pub fn set_body_limit(&mut self, limit: usize) -> &mut Self
set the body limit in bytes for each request
Sourcepub fn timeout(self, timeout: Duration) -> Self
pub fn timeout(self, timeout: Duration) -> Self
set the timeout in seconds for each connection
(0 = no timeout)
Sourcepub fn set_timeout(&mut self, timeout: Duration) -> &mut Self
pub fn set_timeout(&mut self, timeout: Duration) -> &mut Self
set the timeout in seconds for each connection
(0 = no timeout)
Sourcepub fn forward(self, kind: ForwardKind) -> Self
pub fn forward(self, kind: ForwardKind) -> Self
enable support for one of the following “forward” headers or protocols
Supported headers:
Forwarded (“for=”), X-Forwarded-For
X-Client-IP Client-IP, X-Real-IP
CF-Connecting-IP, True-Client-IP
Or using HaProxy protocol.
Sourcepub fn set_forward(&mut self, kind: ForwardKind) -> &mut Self
pub fn set_forward(&mut self, kind: ForwardKind) -> &mut Self
enable support for one of the following “forward” headers or protocols
Same as Self::forward
but without consuming self
.
Sourcepub fn maybe_forward(self, maybe_kind: Option<ForwardKind>) -> Self
pub fn maybe_forward(self, maybe_kind: Option<ForwardKind>) -> Self
maybe enable support for one of the following “forward” headers or protocols.
See Self::forward
for more information.
Sourcepub fn tls_server_config(self, cfg: ServerConfig) -> Self
pub fn tls_server_config(self, cfg: ServerConfig) -> Self
define a tls server cert config to be used for tls terminaton by the serve service.
Sourcepub fn set_tls_server_config(&mut self, cfg: ServerConfig) -> &mut Self
pub fn set_tls_server_config(&mut self, cfg: ServerConfig) -> &mut Self
define a tls server cert config to be used for tls terminaton by the serve service.
Sourcepub fn maybe_tls_server_config(self, cfg: Option<ServerConfig>) -> Self
pub fn maybe_tls_server_config(self, cfg: Option<ServerConfig>) -> Self
define a tls server cert config to be used for tls terminaton by the serve service.
Sourcepub fn http_version(self, version: Version) -> Self
pub fn http_version(self, version: Version) -> Self
set the http version to use for the http server (auto by default)
Sourcepub fn maybe_http_version(self, version: Option<Version>) -> Self
pub fn maybe_http_version(self, version: Option<Version>) -> Self
maybe set the http version to use for the http server (auto by default)
Sourcepub fn set_http_version(&mut self, version: Version) -> &mut Self
pub fn set_http_version(&mut self, version: Version) -> &mut Self
set the http version to use for the http server (auto by default)
Sourcepub fn http_layer<H2>(self, layer: H2) -> ServeServiceBuilder<(H, H2)>
pub fn http_layer<H2>(self, layer: H2) -> ServeServiceBuilder<(H, H2)>
add a custom http layer which will be applied to the existing http layers
Sourcepub fn content_path(self, path: impl Into<PathBuf>) -> Self
pub fn content_path(self, path: impl Into<PathBuf>) -> Self
Set the content path to serve (by default it will serve the rama homepage).
Sourcepub fn maybe_content_path(self, path: Option<PathBuf>) -> Self
pub fn maybe_content_path(self, path: Option<PathBuf>) -> Self
Maybe set the content path to serve (by default it will serve the rama homepage).
Sourcepub fn set_content_path(&mut self, path: impl Into<PathBuf>) -> &mut Self
pub fn set_content_path(&mut self, path: impl Into<PathBuf>) -> &mut Self
Set the content path to serve (by default it will serve the rama homepage).
Sourcepub fn directory_serve_mode(self, mode: DirectoryServeMode) -> Self
pub fn directory_serve_mode(self, mode: DirectoryServeMode) -> Self
Set the DirectoryServeMode
which defines how to serve directories.
By default it will use DirectoryServeMode::HtmlFileList
.
Note that this is only used in case the content path is defined
(e.g. using Self::content_path
)
and that path points to a valid directory.
Sourcepub fn set_directory_serve_mode(
&mut self,
mode: DirectoryServeMode,
) -> &mut Self
pub fn set_directory_serve_mode( &mut self, mode: DirectoryServeMode, ) -> &mut Self
Set the DirectoryServeMode
which defines how to serve directories.
By default it will use DirectoryServeMode::HtmlFileList
.
Note that this is only used in case the content path is defined (e.g. using Self::content_path
)
and that path points to a valid directory.
Source§impl<H> ServeServiceBuilder<H>
impl<H> ServeServiceBuilder<H>
Sourcepub fn build(
self,
executor: Executor,
) -> Result<impl Service<TcpStream, Response = (), Error = Infallible>, BoxError>
pub fn build( self, executor: Executor, ) -> Result<impl Service<TcpStream, Response = (), Error = Infallible>, BoxError>
build a tcp service ready to serve files
Sourcepub fn build_http(
&self,
) -> Result<impl Service<Request, Response: IntoResponse, Error = Infallible> + use<H>, BoxError>
pub fn build_http( &self, ) -> Result<impl Service<Request, Response: IntoResponse, Error = Infallible> + use<H>, BoxError>
build an http service ready to serve files
Trait Implementations§
Source§impl<H: Clone> Clone for ServeServiceBuilder<H>
impl<H: Clone> Clone for ServeServiceBuilder<H>
Source§fn clone(&self) -> ServeServiceBuilder<H>
fn clone(&self) -> ServeServiceBuilder<H>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl<H: Debug> Debug for ServeServiceBuilder<H>
impl<H: Debug> Debug for ServeServiceBuilder<H>
Auto Trait Implementations§
impl<H> Freeze for ServeServiceBuilder<H>where
H: Freeze,
impl<H> !RefUnwindSafe for ServeServiceBuilder<H>
impl<H> Send for ServeServiceBuilder<H>where
H: Send,
impl<H> Sync for ServeServiceBuilder<H>where
H: Sync,
impl<H> Unpin for ServeServiceBuilder<H>where
H: Unpin,
impl<H> !UnwindSafe for ServeServiceBuilder<H>
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
§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> ⓘ
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> ⓘ
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§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
§fn and<P, B, E>(self, other: P) -> And<T, P>
fn and<P, B, E>(self, other: P) -> And<T, P>
Policy
that returns Action::Follow
only if self
and other
return
Action::Follow
. Read more