Gerer les souscription aux variables

This commit is contained in:
2025-10-09 07:00:48 +02:00
parent e5c83d01c0
commit fd1a44b6fa
3 changed files with 140 additions and 109 deletions

View File

@@ -30,28 +30,24 @@
use crate::WebAppExt;
use pmoserver::Server;
use rust_embed::RustEmbed;
use std::future::Future;
use std::pin::Pin;
impl WebAppExt for Server {
fn add_webapp<W>(&mut self, path: &str) -> Pin<Box<dyn Future<Output = ()> + Send + '_>>
async fn add_webapp<W>(&mut self, path: &str)
where
W: RustEmbed + Clone + Send + Sync + 'static,
{
let path = path.to_string();
Box::pin(async move {
self.add_spa::<W>(&path).await;
})
self.add_spa::<W>(&path).await;
}
fn add_webapp_with_redirect<W>(&mut self, path: &str) -> Pin<Box<dyn Future<Output = ()> + Send + '_>>
async fn add_webapp_with_redirect<W>(&mut self, path: &str)
where
W: RustEmbed + Clone + Send + Sync + 'static,
{
let path = path.to_string();
Box::pin(async move {
self.add_spa::<W>(&path).await;
self.add_redirect("/", &path).await;
})
self.add_spa::<W>(&path).await;
self.add_redirect("/", &path).await;
}
}