pub struct ServerBuilder { /* private fields */ }
Expand description
HTTP server builder.
Implementations§
Source§impl ServerBuilder
impl ServerBuilder
Sourcepub fn new(bind_addr: SocketAddr) -> Self
pub fn new(bind_addr: SocketAddr) -> Self
Makes a new ServerBuilder
instance.
Sourcepub fn add_handler<H>(&mut self, handler: H) -> Result<&mut Self>
pub fn add_handler<H>(&mut self, handler: H) -> Result<&mut Self>
Adds a HTTP request handler.
§Errors
If the path and method of the handler conflicts with the already registered handlers,
an ErrorKind::InvalidInput
error will be returned.
Sourcepub fn add_handler_with_options<H, D, E>(
&mut self,
handler: H,
options: HandlerOptions<H, D, E>,
) -> Result<&mut Self>
pub fn add_handler_with_options<H, D, E>( &mut self, handler: H, options: HandlerOptions<H, D, E>, ) -> Result<&mut Self>
Adds a HTTP request handler with the given options.
§Errors
If the path and method of the handler conflicts with the already registered handlers,
an ErrorKind::InvalidInput
error will be returned.
Sourcepub fn logger(&mut self, logger: Logger) -> &mut Self
pub fn logger(&mut self, logger: Logger) -> &mut Self
Sets the logger of the server.
The default value is Logger::root(Discard, o!())
.
Sourcepub fn metrics(&mut self, metrics: MetricBuilder) -> &mut Self
pub fn metrics(&mut self, metrics: MetricBuilder) -> &mut Self
Sets MetricBuilder
used by the server.
The default value is MetricBuilder::default()
.
Sourcepub fn read_buffer_size(&mut self, n: usize) -> &mut Self
pub fn read_buffer_size(&mut self, n: usize) -> &mut Self
Sets the application level read buffer size of the server in bytes.
The default value is 8192
.
Sourcepub fn write_buffer_size(&mut self, n: usize) -> &mut Self
pub fn write_buffer_size(&mut self, n: usize) -> &mut Self
Sets the application level write buffer size of the server in bytes.
The default value is 8192
.
Sourcepub fn decode_options(&mut self, options: DecodeOptions) -> &mut Self
pub fn decode_options(&mut self, options: DecodeOptions) -> &mut Self
Sets the options of the request decoder of the server.
The default value is DecodeOptions::default()
.