pub struct SqlViewerLayer<DB: DatabaseProvider> { /* private fields */ }Expand description
Main layer for integrating SQL viewer into an Axum application
§Example
use axum::Router;
use axum_sql_viewer::SqlViewerLayer;
use sqlx::SqlitePool;
let pool = SqlitePool::connect("sqlite::memory:").await.unwrap();
let viewer = SqlViewerLayer::sqlite("/sql-viewer", pool);
let app = Router::new().merge(viewer.into_router());Implementations§
Source§impl<DB: DatabaseProvider> SqlViewerLayer<DB>
impl<DB: DatabaseProvider> SqlViewerLayer<DB>
Sourcepub fn new(base_path: impl Into<String>, database: DB) -> Self
pub fn new(base_path: impl Into<String>, database: DB) -> Self
Create a new SQL viewer at the given base path
§Arguments
base_path- The URL path where the viewer will be mounted (e.g., “/sql-viewer”)database- The database provider implementation
Sourcepub fn into_router(self) -> Router
pub fn into_router(self) -> Router
Convert into an Axum Router that can be merged
This method consumes the layer and returns a Router that can be merged into your main application router.
The returned router includes:
- Frontend serving at
{base_path}/ - API endpoints at
{base_path}/api/* - Permissive CORS middleware for development
Auto Trait Implementations§
impl<DB> Freeze for SqlViewerLayer<DB>
impl<DB> RefUnwindSafe for SqlViewerLayer<DB>where
DB: RefUnwindSafe,
impl<DB> Send for SqlViewerLayer<DB>
impl<DB> Sync for SqlViewerLayer<DB>
impl<DB> Unpin for SqlViewerLayer<DB>
impl<DB> UnwindSafe for SqlViewerLayer<DB>where
DB: RefUnwindSafe,
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more