-
Notifications
You must be signed in to change notification settings - Fork 69
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
Allow APIRouter to be made from create_service #33
base: main
Are you sure you want to change the base?
Conversation
There is no problem to use APIRouter instead of FastAPI
Allow APIRouter to be made from create_service
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
) | ||
app.include_router(router) | ||
``` | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have not tested it yet but it should be possible to use mount
app = FastAPI()
router = APIRouter()
@app.get("/")
def read_main():
return {"message": "Hello World from main app"}
lang_app: FastAPI = create_service(
"api.ex1:chain",
)
app.mount("/subapi", lang_app)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello.
Yes you are right on this.
But in my use case cannot define FastAPI application.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would your use case work with lang_app.router
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did it solve your issue?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not able to have access to app for my use case.
So the only solution is to do my proposal.
Hi @slamer59, thx for your patch and contribution! Let me test it locally and get back to you. |
There is no problem to use APIRouter instead of FastAPI.
Exemple :
app = FastAPI()
router = APIRouter()
@app.get("/")
def read_main():
return {"message": "Hello World from main app"}
router: APIRouter = create_service(router,
"api.ex1:chain",
)
app.include_router(router)