Robyn
Robyn copied to clipboard
[Feature Request] Allow dependency injection and make the objects accessible in the request object
Current Behavior
No dependency injection is supported right now.
Desired Behavior
Add support for dependency injection. This will allow things like open database connections, loggers to be added once at the top level and be accessible to every route if required.
Something like this
@app.get("/"):
def fx(request, db): # db is possible right now
print(db)
HIgh Level Implementation
- Allow variable params in the callable functions
- Go to the function executors(rust side) and call the functions with variable params
Hii, I am interested in this, I don't really know where to start when we talk about calling the rust side, any comment on this might help me 😄
@Noborita9 , thank you for the interest 😄 I will be happy to guide you.
I just want to confirm if @kliwongan is not working on this in their PR(https://github.com/sansyrox/robyn/pull/363) here.
Sorry for the late response; I would want to work on a similar feature, but I believe that once my work is done, it shouldn't be too difficult to extend the additions to allow for proper dependency injection. I'll make sure of that.
EDIT: Just to clarify I will not be working on dependency injection specifically, just the validation stuff; if you want, you can wait until that's done so that it's easier to work on dependency injection? I should be able to finish it soon.