pub struct ServerBuilder { /* private fields */ }Expand description
Represents the Tii app.
Implementations§
Source§impl ServerBuilder
impl ServerBuilder
Sourcepub fn builder<T: FnOnce(ServerBuilder) -> TiiResult<ServerBuilder>>(
closure: T,
) -> TiiResult<Server>
pub fn builder<T: FnOnce(ServerBuilder) -> TiiResult<ServerBuilder>>( closure: T, ) -> TiiResult<Server>
Build TiiServer using a closure or fn which receives the builder
Sourcepub fn builder_arc<T: FnOnce(ServerBuilder) -> TiiResult<ServerBuilder>>(
closure: T,
) -> TiiResult<Arc<Server>>
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
Sourcepub fn build_arc(self) -> Arc<Server>
pub fn build_arc(self) -> Arc<Server>
This method is equivalent to calling Arc::new(builder.build())
Sourcepub fn type_system(
self,
configurator: impl FnOnce(&mut TypeSystemBuilder),
) -> Self
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.
Sourcepub fn add_router(self, handler: impl Router + 'static) -> Self
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.
Sourcepub fn router<T: FnOnce(RouterBuilder) -> TiiResult<RouterBuilder>>(
self,
builder: T,
) -> TiiResult<Self>
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.
Sourcepub fn with_error_handler(self, handler: ErrorHandler) -> TiiResult<Self>
pub fn with_error_handler(self, handler: ErrorHandler) -> TiiResult<Self>
Sets the error handler for the server.
Sourcepub fn with_not_found_handler(self, handler: NotFoundHandler) -> TiiResult<Self>
pub fn with_not_found_handler(self, handler: NotFoundHandler) -> TiiResult<Self>
Sets the not found handler for the server.
Sourcepub fn with_max_head_buffer_size(self, size: usize) -> TiiResult<Self>
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.
Sourcepub fn with_connection_timeout(
self,
timeout: Option<Duration>,
) -> TiiResult<Self>
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
Sourcepub fn with_read_timeout(self, timeout: Option<Duration>) -> TiiResult<Self>
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.
Sourcepub fn with_write_timeout(self, timeout: Option<Duration>) -> TiiResult<Self>
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.
Sourcepub fn with_keep_alive_timeout(
self,
timeout: Option<Duration>,
) -> TiiResult<Self>
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.
Sourcepub fn with_request_body_timeout(
self,
timeout: Option<Duration>,
) -> TiiResult<Self>
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.