Replies: 2 comments
-
Apologies for the delay; I have a broken finger so typing is harder than usual. I don't think there's a strong advantage of using trillium-api when implementing a handler on a struct, versus implementing trillium::Handler. In theory if MutBorrowConn were public, it would be possible to implement that, but I'd want to understand the use case in more detail before making that change. What do you gain by using trillium-api over implementing Handler? Are you sure you need self in the handler? The connection manager in your example looks like conn state to me. |
Beta Was this translation helpful? Give feedback.
-
@jbr Thanks for your answer, and hope your finger is healing quickly! I think you are right in that i don't really need the api handler here, my use case here is to have a REST api where requests reads state of "ConnectionManager", so probably But maybe it would be beneficial to have all the features of API handler even for this? I mean the same would be true for any other requests, i can ofc implement the same features as the API handler does myself :-) Also do i understand it correctly that it is impossible as is to have a connection state as you mention above if using an API handler? |
Beta Was this translation helpful? Give feedback.
-
Is it possible to pass a function implemented on a struct (self) to router? I would imagine this would work something like the code below, but i cannot get it to compile. Does anyone have any ideas on how to do this?
To clearify, i need to pass either self or Arc<RwLock> into the handler function
Beta Was this translation helpful? Give feedback.
All reactions