pub struct App { /* private fields */ }Expand description
A configured application. Cheap to clone.
Implementations§
Source§impl App
impl App
Sourcepub fn new(routes: Routes) -> AppBuilder
pub fn new(routes: Routes) -> AppBuilder
Start building an application from generated routes.
pub fn config(&self) -> &Config
pub fn environment(&self) -> Environment
pub fn cache(&self) -> &Cache
Sourcepub async fn handle(&self, req: Request) -> Response
pub async fn handle(&self, req: Request) -> Response
Handle one request. This is the adapter surface: the built-in server, tests and serverless adapters all call it.
Sourcepub async fn revalidate_path(&self, path: &str) -> bool
pub async fn revalidate_path(&self, path: &str) -> bool
Re-render path on its next request (ISR) and drop data-cache
entries stored under the same path key.
Sourcepub async fn revalidate_tag(&self, tag: &str) -> usize
pub async fn revalidate_tag(&self, tag: &str) -> usize
Invalidate pages and data tagged with tag. Returns the number of entries removed.
Sourcepub async fn export(&self) -> Result<ExportReport, String>
pub async fn export(&self) -> Result<ExportReport, String>
Render every static route without keeping the result: used by
next-rust build to check that static generation succeeds.
Sourcepub async fn prerender(&self) -> Result<ExportReport, String>
pub async fn prerender(&self) -> Result<ExportReport, String>
Render every static route into the page cache, so the first visitor gets a cached page. Production servers do this in the background at startup.
Source§impl App
impl App
Sourcepub async fn serve(self) -> Result<(), Error>
pub async fn serve(self) -> Result<(), Error>
Bind to the configured address and serve until shutdown.
Sourcepub async fn serve_listener(self, listener: TcpListener) -> Result<(), Error>
pub async fn serve_listener(self, listener: TcpListener) -> Result<(), Error>
Serve on an existing listener (tests, socket activation).
Sourcepub async fn handle_hyper(
&self,
req: Request<Incoming>,
remote: Option<SocketAddr>,
) -> Response<UnsyncBoxBody<Bytes, Box<dyn Error + Send + Sync>>>
pub async fn handle_hyper( &self, req: Request<Incoming>, remote: Option<SocketAddr>, ) -> Response<UnsyncBoxBody<Bytes, Box<dyn Error + Send + Sync>>>
Handle a hyper request (used by the built-in server).