20 lines
580 B
Python
20 lines
580 B
Python
from fastapi import Depends, Request
|
|
|
|
from adapter.di.container import AppContainer
|
|
from usecase.sandbox import CreateSandbox
|
|
|
|
APP_CONTAINER_STATE = 'container'
|
|
APP_CONFIG_STATE = 'config'
|
|
|
|
|
|
def get_container(request: Request) -> AppContainer:
|
|
container = getattr(request.app.state, APP_CONTAINER_STATE, None)
|
|
if not isinstance(container, AppContainer):
|
|
raise RuntimeError('container unavailable')
|
|
return container
|
|
|
|
|
|
def get_create_sandbox(
|
|
container: AppContainer = Depends(get_container),
|
|
) -> CreateSandbox:
|
|
return container.usecases.create_sandbox
|