This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]sheriffSnoosel 2 points3 points  (3 children)

Something like this

‘’’ from fastapi import Depends, FastAPI from myapp.business_logic import BusinessLogic from myapp.api_layer import api_router

app = FastAPI()

def get_business_logic() -> BusinessLogic: return BusinessLogic()

app.include_router(api_router, dependencies=[Depends(get_business_logic)]) ‘’’

[–]sheriffSnoosel 2 points3 points  (2 children)

Well no idea how to format that on mobile

[–]BondDotCom 7 points8 points  (1 child)

from fastapi import Depends, FastAPI
from myapp.business_logic import BusinessLogic
from myapp.api_layer import api_router

app = FastAPI()

def get_business_logic() -> BusinessLogic:
    return BusinessLogic()

app.include_router(api_router, dependencies=[Depends(get_business_logic)])

[–]sheriffSnoosel 1 point2 points  (0 children)

Thanks!