이전 자료에서 Controller - Service - Repository로 이루어진 Layered Architecture에 대해 배웠습니다. 이번에는 파이썬에서 의존성 주입을 위해 많이 사용되는 Depedency Injector에 대해 배워보겠습니다.

Dependency Injector란?

실습 준비

  1. 서버 실행 스크립트 start.sh

    $ bash start.sh
    
    INFO:     Will watch for changes in these directories: ['/Users/.../fastapi-tutorial']
    INFO:     Uvicorn running on <http://127.0.0.1:8000> (Press CTRL+C to quit)
    INFO:     Started reloader process [22898] using WatchFiles
    INFO:     Started server process [22903]
    INFO:     Waiting for application startup.
    INFO:     Application startup complete.
    

Container 정의

의존성 주입