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

Allow APIRouter to be made from create_service #33

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

slamer59
Copy link

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)

There is no problem to use APIRouter instead of FastAPI
Allow APIRouter to be made from create_service
@vercel
Copy link

vercel bot commented Aug 24, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
langcorn ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 24, 2023 3:18pm

)
app.include_router(router)
```

Copy link
Owner

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)

Copy link
Author

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.

Copy link
Owner

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?

Copy link
Owner

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?

Copy link
Author

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.

@msoedov
Copy link
Owner

msoedov commented Aug 24, 2023

Hi @slamer59, thx for your patch and contribution! Let me test it locally and get back to you.

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

Successfully merging this pull request may close these issues.

None yet

2 participants