Эта страница ещё не переведена
Ниже показан английский оригинал.
Viewer
render_viewer_html returns a self-contained HTML page that renders the document with the AsyncAPI React component.
The page loads the document from the URL it is given, so the service serves two routes: the document and the page.
The function renders a string; serving it is the job of the HTTP stack the service already runs.
examples/asyncapi_http.rs in the repository serves both routes with axum.
The component and its stylesheet load from jsDelivr, at a pinned version.
ViewerOptions sets the page title and another asset base with cdn_base: a mirror, or the service's own assets where the network has no way out.
The example runs with cargo test --example asyncapi_generation --features macros,memory,asyncapi.
Example
/// The page the service serves at `/docs`: it renders the document served at `/asyncapi.json`.
fn docs_page() -> String {
let options = ViewerOptions::default().title("Orders events");
render_viewer_html("/asyncapi.json", &options)
}