-
-
Notifications
You must be signed in to change notification settings - Fork 13
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
How to inject router in class? #127
Comments
Hello @fbrodrigorezino can you please include a simple example of what you are planning to use? |
I'm trying to use FastAPI as class, but in the new version, I didn't find a way to do it, everything became decorators. I'm sure I'm missing something... here goes some code. Pseudo code:
I removed some of the code that is not necessary, but I'm using it via containers like:
But it does not matter in this case. I didn't find a way to continue the class structure for the new version. I think I'm missing something, as I'm sure you support it, given it's the name of the lib. So if you can give me some directions. thank you! |
Hi Yezz, I've been using version 2 for a long time.
And one of the reasons is that, as the name package suggests, I can use it as a class and inject it into different routers according to my code needs, tests, use inheritance, use as a container, etc.
But version 3 and above no longer use the class format, such as the Routable.
So I was using the end:
app.include_router(container[IRestAPI].router)
How can I still use the fastapi-class as a class?
Thank you
The text was updated successfully, but these errors were encountered: