I have an IFoo
instance which I need to use as per request instance. Here is how my startup class look like:
public void Configuration(IAppBuilder app)
{
HttpConfiguration config = new HttpConfiguration();
config.Routes.MapHttpRoute("DefaultHttpRoute", "api/{controller}");
app.Use<RandomTextMiddleware>()
.UseWebApi(config);
}
RandomTextMiddleware
is a pass-through middleware and I need an instance of IFoo
implementation there. I also need an instance of IFoo
implementation inside my Web API pipeline.
How would you solve this problem so that I have the same instance of IFoo
implementation inside the RandomTextMiddleware
and the Web API pipeline per HTTP request?
@panesofglass
Here is an example:
OAuthAuthorizationServerMiddleware
(UseOAuthAuthorizationServer
).Here is my provider:
Noticed
requestContainer.GetService<IClientManager>()
?OAuthAuthorizationServerMiddleware
is still reusable and I'm able to use my DI implementation on top of OWIN environment, w/o any coupling at all.