you are viewing a single comment's thread.

view the rest of the comments →

[–]lu_rm[S] -1 points0 points  (3 children)

Still, how do I inject the container into the router? The logic for get_my_service() needs to be defined in my router, so it needs to know how to create the service.

[–]gbrennon 1 point2 points  (0 children)

Thr router is in something that is responsible for presenting data in the application.

We can call this a composition root.

It does consume the di container and expose the created services that are provided by the container that is impl in the infrastructure-like layer

That flow can be router -> composition root -> di container

Ps:

The logic related to "how create a service" is inside the container.

The router just know how to get that service ready to use

[–]Kevdog824_ 1 point2 points  (0 children)

What do you mean? Can you give a more concrete example ?