Skip to content

How to access Ocelot config outside of Ocelot pipeline? #1871

Answered by raman-m
rwestonbutler asked this question in Q&A
Discussion options

You must be logged in to vote

@rwestonbutler on Jan 16, 2019:

Is there a way to access the strongly typed Ocelot configuration from outside of the Ocelot pipeline in a delegating handler or middleware, maybe have it injected via DI?

Please try to inject the following interface objects:

  • IInternalConfiguration: see usage and code. It has Routes property and you have to find your route mannually.
  • IOptionsMonitor<IInternalConfiguration>: see usage and code. But it requires to write valid path to extract.
  • IOptions<FileConfiguration>: see usage and code. Seems it is the best option!

Hope it helps!
Let us know your testing results please!

Replies: 4 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by raman-m
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
duplicate Duplicated by another issue question Initially seen a question could become a new feature or bug or closed ;)
3 participants
Converted from issue

This discussion was converted from issue #751 on January 02, 2024 11:36.