impl<R: Responder> Responder for MutexGuard<R> #2615
-
i have a server with a page who updates every 10 seconds, so it is not 'static, such page is stored in a Mutex, but if i pass the MutexGuard, rocket doesn't accept it, i think a implementation for this should be: use the inside, and unlock it solution: implement MutexGuard for Responder, i think it should look like Box, but with some modifications: impl<'r, 'o: 'r, T: Responder<'r, 'o> + Sized> Responder<'r, 'o> for Box<T> {
fn respond_to(self, req: &'r Request<'_>) -> response::Result<'o> {
let inner = *self;
inner.respond_to(req)
}
} extra: maybe also implement with RwLockReadGuard or such |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
It sounds like this is a problem with your approach, not functionality missing in Rocket. Your data probably is I'm not sure what you're doing, but perhaps if you gave an example we could be of more help. I'm converting this to a discussion. |
Beta Was this translation helpful? Give feedback.
It sounds like this is a problem with your approach, not functionality missing in Rocket. Your data probably is
'static
, seeing as you're sharing it across the application, so this isn't part of the problem. Returning aMutexGuard
from a handler would mean maintaining the lock until the response is completely written, which is prone to DoS issues (the client can effectively hold your lock as long as they want.) You probably want to find some way of avoiding trying to hold a lock across a handler invocation.I'm not sure what you're doing, but perhaps if you gave an example we could be of more help. I'm converting this to a discussion.