Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request] Allow dependency injection and make the objects accessible in the request object #214

Closed
sansyrox opened this issue Jun 22, 2022 · 4 comments

Comments

@sansyrox
Copy link
Member

sansyrox commented Jun 22, 2022

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
@Noborita9
Copy link
Contributor

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 😄

@sansyrox
Copy link
Member Author

sansyrox commented Mar 9, 2023

@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(#363) here.

@kliwongan
Copy link
Contributor

kliwongan commented Mar 19, 2023

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.

@sansyrox
Copy link
Member Author

implemented.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants