pub struct Application { /* private fields */ }Implementations§
Source§impl Application
impl Application
Sourcepub fn new(routes: Routes) -> Result<Self, RouteBuildError>
pub fn new(routes: Routes) -> Result<Self, RouteBuildError>
Build an application from its route declarations.
§Errors
Returns a route build error when route patterns or names are invalid.
Sourcepub fn multi() -> MultiApplicationBuilder
pub fn multi() -> MultiApplicationBuilder
Start building an application composed of independently scoped modules.
pub fn max_body_size(self, bytes: usize) -> Self
pub fn header_read_timeout(self, timeout: Duration) -> Self
pub fn body_read_timeout(self, timeout: Duration) -> Self
pub fn graceful_shutdown_timeout(self, timeout: Duration) -> Self
Sourcepub const fn http_protocol(self, protocol: HttpProtocol) -> Self
pub const fn http_protocol(self, protocol: HttpProtocol) -> Self
Select which HTTP protocol versions the built-in TCP server accepts.
Sourcepub fn metrics(self, metrics: Metrics) -> Self
pub fn metrics(self, metrics: Metrics) -> Self
Attach the process metrics registry used for connection and TLS telemetry.
pub fn router(&self) -> &Router
pub async fn handle(&self, request: Request) -> Response
Sourcepub async fn bind<A>(self, address: A) -> Result<Server, ServerError>where
A: ToSocketAddrs,
pub async fn bind<A>(self, address: A) -> Result<Server, ServerError>where
A: ToSocketAddrs,
Bind the application to a TCP address without accepting connections yet.
§Errors
Returns an I/O error when the address cannot be resolved or bound.
Sourcepub async fn bind_tls<A>(
self,
address: A,
tls: TlsConfig,
) -> Result<Server, ServerError>where
A: ToSocketAddrs,
pub async fn bind_tls<A>(
self,
address: A,
tls: TlsConfig,
) -> Result<Server, ServerError>where
A: ToSocketAddrs,
Bind an HTTPS listener using rustls and ALPN.
§Errors
Returns an I/O error when the address cannot be resolved or bound.
Sourcepub async fn spawn<A>(self, address: A) -> Result<ServerHandle, ServerError>where
A: ToSocketAddrs,
pub async fn spawn<A>(self, address: A) -> Result<ServerHandle, ServerError>where
A: ToSocketAddrs,
Bind and run the application in a Tokio task.
§Errors
Returns an I/O error when the listener cannot be created.
Sourcepub async fn spawn_tls<A>(
self,
address: A,
tls: TlsConfig,
) -> Result<ServerHandle, ServerError>where
A: ToSocketAddrs,
pub async fn spawn_tls<A>(
self,
address: A,
tls: TlsConfig,
) -> Result<ServerHandle, ServerError>where
A: ToSocketAddrs,
Bind and run an HTTPS application in a Tokio task.
§Errors
Returns an I/O error when the listener cannot be created.