fix: inject ReloadService to API class
This commit is contained in:
parent
604381348a
commit
8f4dc486ac
2 changed files with 7 additions and 0 deletions
|
|
@ -10,6 +10,7 @@ from karl.api.models import Request
|
||||||
from karl.core.injects import AutowireSupport
|
from karl.core.injects import AutowireSupport
|
||||||
from karl.core.woodpecker import Woodpecker
|
from karl.core.woodpecker import Woodpecker
|
||||||
from karl.model.webhook import WoodpeckerEvent, ReloadEvent
|
from karl.model.webhook import WoodpeckerEvent, ReloadEvent
|
||||||
|
from services.reload import ReloadService
|
||||||
|
|
||||||
router = APIRouter()
|
router = APIRouter()
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
@ -21,6 +22,7 @@ async def root():
|
||||||
|
|
||||||
@cbv(router)
|
@cbv(router)
|
||||||
class APIv1:
|
class APIv1:
|
||||||
|
reload: ReloadService = Depends(AutowireSupport.reload)
|
||||||
woodpecker: Woodpecker = Depends(AutowireSupport.woodpecker)
|
woodpecker: Woodpecker = Depends(AutowireSupport.woodpecker)
|
||||||
bus: EventBus = Depends(AutowireSupport.bus)
|
bus: EventBus = Depends(AutowireSupport.bus)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ from bubus import EventBus
|
||||||
from injectable import inject
|
from injectable import inject
|
||||||
|
|
||||||
from karl.core.woodpecker import Woodpecker
|
from karl.core.woodpecker import Woodpecker
|
||||||
|
from services.reload import ReloadService
|
||||||
|
|
||||||
|
|
||||||
class AutowireSupport:
|
class AutowireSupport:
|
||||||
|
|
@ -10,6 +11,10 @@ class AutowireSupport:
|
||||||
def woodpecker():
|
def woodpecker():
|
||||||
return inject(Woodpecker)
|
return inject(Woodpecker)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def reload():
|
||||||
|
return inject(ReloadService)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def bus():
|
def bus():
|
||||||
return inject(EventBus)
|
return inject(EventBus)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue