axum-sessions
axum-sessions copied to clipboard
Add a listener trait to listen to the creation, update and destruction of sessions
Add a listener trait to listen to the creation, update and destruction of sessions
Thanks for the suggestion. Do you have an idea of what the implementation would look like?
I think it should be similar to the listener API of the javaee servlet
trait SessionListener {
fn onSessionCreated(self: Self, event: SessionEvent);
fn onSessionDestoryed(self: Self, event: SessionEvent);
fn onAttributeAdded(self: Self, event: SessionAttributeEvent);
fn onAttributeReplaced(self: Self, event: SessionAttributeEvent);
fn onAttributeRemoved(self: Self, event: SessionAttributeEvent);
}
I suggest a slightly different interface:
pub enum AttributeEvent {
Add(AddEvent),
Replace(ReplaceEvent),
Remove(RemoveEvent)
}
pub enum SessionEvent {
Create(CreateEvent),
Destroy(DestroyEvent),
Modify(AttributeEvent)
}
trait SessionListener {
fn onEvent(&self, event: SessionEvent);
}