mirror of
https://github.com/Djeeberjr/fw-anwesenheit.git
synced 2026-05-01 02:59:09 +00:00
fixed webserver not working
- shared store in main - multiple tasks for webserver
This commit is contained in:
31
src/webserver/app.rs
Normal file
31
src/webserver/app.rs
Normal file
@@ -0,0 +1,31 @@
|
||||
use alloc::rc::Rc;
|
||||
use embassy_sync::{blocking_mutex::raw::CriticalSectionRawMutex, mutex::Mutex};
|
||||
use picoserve::{AppWithStateBuilder, routing::get};
|
||||
|
||||
use crate::{
|
||||
webserver::{
|
||||
api::{add_mapping, get_mapping},
|
||||
assets::Assets,
|
||||
}, UsedStore,
|
||||
};
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct AppState {
|
||||
pub store: Rc<Mutex<CriticalSectionRawMutex, UsedStore>>,
|
||||
}
|
||||
|
||||
pub struct AppProps;
|
||||
|
||||
impl AppWithStateBuilder for AppProps {
|
||||
type State = AppState;
|
||||
type PathRouter = impl picoserve::routing::PathRouter<AppState>;
|
||||
|
||||
fn build_app(self) -> picoserve::Router<Self::PathRouter, AppState> {
|
||||
picoserve::Router::from_service(Assets)
|
||||
.route("/api/mapping", get(get_mapping).post(add_mapping))
|
||||
// .route(
|
||||
// "/api/idevent",
|
||||
// get(move || response::EventStream(Events(self.chan))),
|
||||
// )
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user