Get Started

Page in progress

This documentation page is actively being expanded and refined.

Service Injection

Inject a service into a controller instead of assembling objects by hand.

Get StartedFirst Service

Autumn uses explicit constructor-based dependency declarations.
If a controller needs a service, just add it to __init__ and the container will provide the required instance automatically.

Controller + Service

from autumn.controller import get
from autumn.response import JSONResponse

from app import app

@app.rest(prefix = '/hello')
class HelloController:
    def __init__(self, service: GreetingService):
        self.service = service

    @get('/')
    async def index(self) -> JSONResponse:
        return JSONResponse({
            'message' : self.service.build_message()
        })

What This Gives You

  • Dependencies are declared explicitly in the constructor.
  • The controller is not responsible for creating services.
  • The DI container manages the object lifecycle.

This is the Autumn approach: dependencies stay explicit while component wiring happens automatically.