pub struct ServerBuilder { /* private fields */ }
Expand description
A builder struct for starting a test Server
.
Implementations§
Source§impl ServerBuilder
impl ServerBuilder
Sourcepub fn new(extensions: Extensions, options: Options) -> Self
pub fn new(extensions: Extensions, options: Options) -> Self
Creates a new builder with extensions
and options
,
with HTTPS enabled. To disable this, call Self::http
.
Use Self::default()
for a default configuration.
Also see the From
implementations for this struct.
The inner Extensions
can be modified with Self::with_extensions
and the host::Options
with Self::with_options
Sourcepub fn with_extensions(self, mutation: impl Fn(&mut Extensions)) -> Self
pub fn with_extensions(self, mutation: impl Fn(&mut Extensions)) -> Self
Modifies the internal Extensions
with mutation
.
If you already have a Extensions
, use From
.
Sourcepub fn with_options(self, mutation: impl Fn(&mut Options)) -> Self
pub fn with_options(self, mutation: impl Fn(&mut Options)) -> Self
Modifies the internal host::Options
with mutation
.
If you already have a host::Options
, use From
.
Sourcepub fn path(self, path: impl AsRef<str>) -> Self
pub fn path(self, path: impl AsRef<str>) -> Self
Sets the Host::path
of this server.
Sourcepub fn enable_handover(self, path: impl AsRef<Path>) -> Self
pub fn enable_handover(self, path: impl AsRef<Path>) -> Self
Enables handover for this server.
If you are starting the server which will take over the requests, use Self::handover_from
instead.
The communication socket is at path
.
Sourcepub fn handover_from(self, previous: &Server) -> Self
pub fn handover_from(self, previous: &Server) -> Self
“Steals” the requests from previous
.
§Panics
Will panic if Self::enable_handover
wasn’t called on previous
’s ServerBuilder
.