Using app.Environment in HttpRequestInterceptor?

70 Views Asked by At

In Program.cs I can use

app.Environment.IsDevelopment()

Now I have a custom HttpRequestInterceptor : DefaultHttpRequestInterceptor with a method

public override ValueTask OnCreateAsync(HttpContext context,
IRequestExecutor requestExecutor, IQueryRequestBuilder requestBuilder,
CancellationToken cancellationToken)

How can I get access to app.Environment.IsDevelopment() in that method? (I want to set some kind of faked authentication during development)

1

There are 1 best solutions below

0
Tobias Tengler On BEST ANSWER

You can inject the IWebHostEnvironment through the constructor of the HttpRequestInterceptor and perform your IsDevelopment check on that injected instance.