pub struct SwaggerUiHandler { /* private fields */ }Expand description
Swagger UI 处理器
实现了Silent的Handler trait,可以直接添加到路由中。 负责处理Swagger UI相关的所有请求,包括:
- Swagger UI 静态资源
- OpenAPI 规范JSON
- 重定向到Swagger UI主页
Implementations§
Source§impl SwaggerUiHandler
impl SwaggerUiHandler
Sourcepub fn with_custom_api_doc_path(
ui_path: &str,
api_doc_path: &str,
openapi: OpenApi,
) -> Result<Self>
pub fn with_custom_api_doc_path( ui_path: &str, api_doc_path: &str, openapi: OpenApi, ) -> Result<Self>
Sourcepub fn with_options(
ui_path: &str,
openapi: OpenApi,
options: SwaggerUiOptions,
) -> Result<Self>
pub fn with_options( ui_path: &str, openapi: OpenApi, options: SwaggerUiOptions, ) -> Result<Self>
使用自定义选项创建处理器
Sourcepub fn into_route(self) -> Route
pub fn into_route(self) -> Route
将处理器转换为可直接挂载的 Route 树
自动在 <ui_path> 下注册以下路由(GET/HEAD):
<ui_path><ui_path>/openapi.json<ui_path>/<path:**>
Trait Implementations§
Source§impl Clone for SwaggerUiHandler
impl Clone for SwaggerUiHandler
Source§fn clone(&self) -> SwaggerUiHandler
fn clone(&self) -> SwaggerUiHandler
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Handler for SwaggerUiHandler
impl Handler for SwaggerUiHandler
Source§impl RouterAdapt for SwaggerUiHandler
impl RouterAdapt for SwaggerUiHandler
fn into_router(self) -> Route
Auto Trait Implementations§
impl Freeze for SwaggerUiHandler
impl RefUnwindSafe for SwaggerUiHandler
impl Send for SwaggerUiHandler
impl Sync for SwaggerUiHandler
impl Unpin for SwaggerUiHandler
impl UnwindSafe for SwaggerUiHandler
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more