File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- from fastapi import APIRouter
2- from fastapi_restful . cbv import cbv
1+ from dependency_injector . wiring import inject , Provide
2+ from fastapi import APIRouter , Depends
33
4- from .service import SpotifyService
4+ from app .container import Container
5+ from app .spotify .schemas import Device
6+ from app .spotify .service import SpotifyService
57
68spotify_router = APIRouter ()
79
810
9- @cbv (spotify_router )
10- class SpotifyController :
11- def __init__ (self ):
12- self .spotify_service = SpotifyService ()
13-
14- @spotify_router .get ("/devices" )
15- def get_devices (self ):
16- return self .spotify_service .get_devices ()
11+ @spotify_router .get ("/devices" )
12+ @inject
13+ def get_devices (
14+ spotify_service : SpotifyService = Depends (Provide [Container .spotify_service ]),
15+ ) -> list [Device ]:
16+ return spotify_service .refresh_devices ()
You can’t perform that action at this time.
0 commit comments