mirror of
https://github.com/t8y2/dbx.git
synced 2026-10-30 08:20:33 +00:00
Introduce src-web (axum HTTP server) exposing all 43 database operations as REST APIs with SSE streaming for AI, transfers, and SQL file execution. Frontend adapts automatically between Tauri and HTTP backends via api.ts. Includes password authentication, Docker packaging, and login page.
15 lines
458 B
Rust
15 lines
458 B
Rust
use axum::response::sse::{Event, KeepAlive, Sse};
|
|
use futures::stream::Stream;
|
|
use tokio::sync::broadcast;
|
|
|
|
pub fn sse_from_channel(
|
|
mut rx: broadcast::Receiver<String>,
|
|
) -> Sse<impl Stream<Item = Result<Event, std::convert::Infallible>>> {
|
|
let stream = async_stream::stream! {
|
|
while let Ok(data) = rx.recv().await {
|
|
yield Ok(Event::default().data(data));
|
|
}
|
|
};
|
|
Sse::new(stream).keep_alive(KeepAlive::default())
|
|
}
|