prologue
prologue copied to clipboard
UserContext inits evey rest call
I added echo to the extend method, and noticed that it fires every time. This means that a new connection to mongo is opened every time. Also because of this, I can't mutate the data inside the UserContext to implement an InMemory session that uses TableRef instead of mongo.
Here my test project https://github.com/gavr123456789/full-stack-try/blob/main/backend/Nim/app.nim#L10
I think it can be related to https://github.com/planety/prologue/issues/137
Yeah, I think global variables are still needed for extend. Now extend is limited to accepting no externel arguments. I think it can probably be changed into accepting a pointer from users.
Yes, for me it looks like a pretty critical problem, it turns out state can only be stored in databases.
Oh, and ofc, creating new Database connection for each call is the biggest problem here. I will try use session, but I think context is more suitable place
@gavr123456789 I am slightly confused, isn't the extend proc being called once per request exactly what is desired?
My understanding of extending context so far is, that for every request that comes in, prologues creates a Context
object that it passes along and that you can modify to extend it with your own fields before it is passed along to the controller. Doing the conversion from the normal context to your custom context has to be done in a middleware and is done every request.
Is that not how it's supposed to be done? I'm pretty sure I'm having a lot of misunderstandings here, I'm just not spotting where they are.