Interop with existing aspnet minimal api - request scoped classes? #1600
nicholas-brooks
started this conversation in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
This is more of a "this is a bit painful, wouldn't it be nice...".
I am integrating wolverine http into an existing asp.net minimal api application. This application is multi-tenant and talks to two different database systems, one marten (postgres) and a legacy database (SAP SQL Anywhere). We use jwt tokens for auth and the jwt has an embedded tenant identifier in them which we use to determine which database to talk to (both marten and the legacy one).
The marten side uses the
opts.TenantId.DetectWith<MyTenantIdDetection>()
feature however the non-marten side uses a customTenantContext
request scoped object that gets populated via a aspnet middleware (app.UseMiddleware<RequestContextMiddleware>()
)e.g.
To use the existing request scoped code we have (a lot of it references
ITenantContext
), we end up using a locator pattern by injectingIServiceProvider
into the Wolverine Http Handler then getting the required service from that.e.g.
So, the thought was, it would make life easier to be able to tell the Wolverine HTTP handlers (or the validator/loader methods) that, yes, I do wish to use these request scoped classes and I do acknowledge that performance will suffer.
e.g.
ILegacyDb
is but one example (a fake example to make the point) of the many request scoped classes we have and need to use.Is there another way we could do this?
Beta Was this translation helpful? Give feedback.
All reactions