BotApplication.UseMiddleware(ITurnMiddleware) Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Adds the specified turn middleware to the middleware pipeline.
public Microsoft.Teams.Core.ITurnMiddleware UseMiddleware(Microsoft.Teams.Core.ITurnMiddleware middleware);
member this.UseMiddleware : Microsoft.Teams.Core.ITurnMiddleware -> Microsoft.Teams.Core.ITurnMiddleware
Public Function UseMiddleware (middleware As ITurnMiddleware) As ITurnMiddleware
Parameters
- middleware
- ITurnMiddleware
The middleware component to add to the pipeline. Cannot be null.
Returns
The ITurnMiddleware instance representing the middleware pipeline.
Remarks
Middleware components execute in the order they are registered. Each middleware can inspect or modify the activity, perform side effects (such as logging), or short-circuit the pipeline by not calling NextTurn.
bot.UseMiddleware(new MyLoggingMiddleware());
bot.UseMiddleware(new MyAuthMiddleware());
// Pipeline order: MyLoggingMiddleware → MyAuthMiddleware → OnActivity