Struct fibers_http_server::ServerBuilder
source · pub struct ServerBuilder { /* private fields */ }
Expand description
HTTP server builder.
Implementations
sourceimpl 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>where
H: HandleRequest,
H::Decoder: Default,
H::Encoder: Default,
pub fn add_handler<H>(&mut self, handler: H) -> Result<&mut Self>where
H: HandleRequest,
H::Decoder: Default,
H::Encoder: Default,
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>where
H: HandleRequest,
D: Factory<Item = H::Decoder> + Send + Sync + 'static,
E: Factory<Item = H::Encoder> + Send + Sync + 'static,
pub fn add_handler_with_options<H, D, E>(
&mut self,
handler: H,
options: HandlerOptions<H, D, E>
) -> Result<&mut Self>where
H: HandleRequest,
D: Factory<Item = H::Decoder> + Send + Sync + 'static,
E: Factory<Item = H::Encoder> + Send + Sync + 'static,
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()
.