A logical component (a class or a method) can be configured into a middleware by registering it under the Configure() method of the Startup class. It can be done as below.
app.UseMiddleware<MyClass>();
for a class which takes a constructor parameter of RequestDelegate and uses it to navigate to next component, or a simple method delegate within the Configure method as.
app.Use(async (context, next) => {
// some logic
await next.Invoke();
});