utoipa_redoc/axum.rs
1#![cfg(feature = "axum")]
2
3use axum::response::Html;
4use axum::{routing, Router};
5
6use crate::{Redoc, Spec};
7
8impl<S: Spec, R> From<Redoc<S>> for Router<R>
9where
10 R: Clone + Send + Sync + 'static,
11{
12 fn from(value: Redoc<S>) -> Self {
13 let html = value.to_html();
14 Router::<R>::new().route(
15 value.url.as_ref(),
16 routing::get(move || async { Html(html) }),
17 )
18 }
19}