ServerBuilder

Struct ServerBuilder 

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

Represents the Tii app.

Implementations§

Source§

impl ServerBuilder

Source

pub fn builder<T: FnOnce(ServerBuilder) -> TiiResult<ServerBuilder>>( closure: T, ) -> TiiResult<Server>

Build TiiServer using a closure or fn which receives the builder

Source

pub fn builder_arc<T: FnOnce(ServerBuilder) -> TiiResult<ServerBuilder>>( closure: T, ) -> TiiResult<Arc<Server>>

Build Arc<TiiServer> using a closure or fn which receives the builder

Source

pub fn build(self) -> Server

This method creates the HttpServer from the builder.

Source

pub fn build_arc(self) -> Arc<Server>

This method is equivalent to calling Arc::new(builder.build())

Source

pub fn type_system( self, configurator: impl FnOnce(&mut TypeSystemBuilder), ) -> Self

Configures the type system that will be used to cast entity types to dynamic implementations. This is primarily needed for complex filters. For applications that do not require dynamic casting during the filter stage configuring the TypeSystem is not needed.

Source

pub fn add_router(self, handler: impl Router + 'static) -> Self

Adds a new host sub-app to the server. The host can contain wildcards, for example *.example.com.

§Panics

This function will panic if the host is equal to *, since this is the default host. If you want to add a route to every host, simply add it directly to the main app.

Source

pub fn router<T: FnOnce(RouterBuilder) -> TiiResult<RouterBuilder>>( self, builder: T, ) -> TiiResult<Self>

Adds a new router to the server and calls the closure with the new router so it can be configured.

Source

pub fn with_error_handler(self, handler: ErrorHandler) -> TiiResult<Self>

Sets the error handler for the server.

Source

pub fn with_not_found_handler(self, handler: NotFoundHandler) -> TiiResult<Self>

Sets the not found handler for the server.

Source

pub fn with_max_head_buffer_size(self, size: usize) -> TiiResult<Self>

Sets the maximum head buffer size. Default value is 8192.

This affects the maximum permitted length of a header name + value pair as well as the maximum length of the status line and therefore the url.

This value includes protocol overhead such as the “: “ separator between header name/value pairs as well as the HTTP Method and protocol version and the CRLF trailer of each line.

Setting this value to below a minimum of 0x100/256 is prevented and will cause this fn to return Err.

Source

pub fn with_connection_timeout( self, timeout: Option<Duration>, ) -> TiiResult<Self>

Sets the connection timeout, the amount of time before tii will close the connection if it sends no data to tii. If this value is not set then Tii will use the read_timeout for this purpose

Source

pub fn with_read_timeout(self, timeout: Option<Duration>) -> TiiResult<Self>

Sets the read timeout the amount of time before tii will time out a connection when reading data at any point. Different timeouts might overwrite this value for certain aspects. Default is None = Infinite timeout.

Source

pub fn with_write_timeout(self, timeout: Option<Duration>) -> TiiResult<Self>

Sets the write timeout the amount of time before tii will time out a connection when writing data to the underlying connection at any point. Default is None = Infinite timeout.

Source

pub fn with_keep_alive_timeout( self, timeout: Option<Duration>, ) -> TiiResult<Self>

Sets the keep alive timeout. Setting this to None (The Default) will make tii use the read timeout instead. Setting this value to 0 will disable keep-alives and cause Tii to signal to the client that keep-alives are not supported by setting “Connection: Close” on every HTTP1/1 response.

Otherwise, tii will wait this amount of time for the client to send at least 1 byte of the next request.

Source

pub fn with_request_body_timeout( self, timeout: Option<Duration>, ) -> TiiResult<Self>

Sets the amount of time tii will wait for the client to produce at least a single byte of a request body before returning the TimedOut error. A value of None will cause the read timeout to be used.

Source

pub fn ok(self) -> TiiResult<Self>

Helper fn to make builder code look a bit cleaner

Trait Implementations§

Source§

impl Default for ServerBuilder

Source§

fn default() -> Self

Initialises a new Tii app.

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> Same for T

Source§

type Output = T

Should always be Self
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.