Struct ServerBuilder

Source
pub struct ServerBuilder { /* private fields */ }
Expand description

HTTP server builder.

Implementations§

Source§

impl ServerBuilder

Source

pub fn new(bind_addr: SocketAddr) -> Self

Makes a new ServerBuilder instance.

Source

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.

Source

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.

Source

pub fn logger(&mut self, logger: Logger) -> &mut Self

Sets the logger of the server.

The default value is Logger::root(Discard, o!()).

Source

pub fn metrics(&mut self, metrics: MetricBuilder) -> &mut Self

Sets MetricBuilder used by the server.

The default value is MetricBuilder::default().

Source

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.

Source

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.

Source

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().

Source

pub fn finish<S>(self, spawner: S) -> Server
where S: Spawn + Send + 'static,

Builds a HTTP server with the given settings.

Trait Implementations§

Source§

impl Debug for ServerBuilder

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> MaybeSendSync for T