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

Simplify access to env parameter from fastapi #1745

Merged
merged 1 commit into from
Mar 7, 2024

Conversation

hoodmane
Copy link
Contributor

According to the suggestion I got here:
fastapi/fastapi#11219 (reply in thread) this makes it possible to get access to env in fastapi as follows:

from asgi import env

@app.get("/hello")
async def root(env=env):
    return {"message": "Hello World", "secret": env.secret}

@hoodmane hoodmane marked this pull request as ready for review February 29, 2024 05:38
@hoodmane hoodmane requested review from a team as code owners February 29, 2024 05:38
According to the suggestion I got here:
fastapi/fastapi#11219 (reply in thread)
this makes it possible to get access to `env` in fastapi as follows:
```
from asgi import env

@app.get("/hello")
async def root(env=env):
    return {"message": "Hello World", "secret": env.secret}
```
@hoodmane hoodmane force-pushed the hoodmane/cleaner-fastapi-env branch from 9f0937c to 9b532c3 Compare March 7, 2024 15:44
@hoodmane hoodmane merged commit d77fabd into main Mar 7, 2024
11 checks passed
@hoodmane hoodmane deleted the hoodmane/cleaner-fastapi-env branch March 7, 2024 16:26
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.

2 participants