Skip to content

Service Example #94

Answered by scottoffen
seikosantana asked this question in Q&A
Discussion options

You must be logged in to vote

It's for dependency injection. You shouldn't need to touch it in your routes, but the router uses it to resolve dependencies when running the routes (such as injecting loggers). You can see it in action in the Sample project.

  • In Startup.cs I configure services to be injected, such as logging and HttpClient.

  • In my resources, you can see that I inject a logger, even if I don't use it.

  • In the GitHub resource, I use the configured HttpClient to act as a pass-though to the GitHub api.

All this, via the magic of dependency injection!

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by scottoffen
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants