Skip to main content

serve

Function serve 

Source
pub async fn serve(app: App, addr: impl Into<String>) -> Result<(), ServeError>
Expand description

Convenience function to serve an App on the given address.

This is equivalent to calling app.serve(addr) but can be more ergonomic in some contexts.

§Example

use fastapi::prelude::*;
use fastapi_http::serve;

let app = App::builder()
    .get("/", |_, _| async { Response::ok() })
    .build();

serve(app, "0.0.0.0:8080").await?;