diff options
Diffstat (limited to 'src/expire.rs')
| -rw-r--r-- | src/expire.rs | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/expire.rs b/src/expire.rs new file mode 100644 index 0000000..16006d1 --- /dev/null +++ b/src/expire.rs @@ -0,0 +1,20 @@ +use axum::{ + extract::{Request, State}, + middleware::Next, + response::Response, +}; + +use crate::{app::App, clock::RequestedAt, error::Internal}; + +// Expires messages and channels before each request. +pub async fn middleware( + State(app): State<App>, + RequestedAt(expired_at): RequestedAt, + req: Request, + next: Next, +) -> Result<Response, Internal> { + app.logins().expire(&expired_at).await?; + app.events().expire(&expired_at).await?; + app.channels().expire(&expired_at).await?; + Ok(next.run(req).await) +} |
