コード例 #1
0
ファイル: BotwinExtensions.cs プロジェクト: gep13/Botwin
 private static void ApplyGlobalBeforeHook(IApplicationBuilder builder, BotwinOptions options)
 {
     if (options?.Before != null)
     {
         builder.Use(async(ctx, next) =>
         {
             var carryOn = await options.Before(ctx); //TODO Check if return Task.CompletedTask will it continue
             if (carryOn)
             {
                 await next();
             }
         });
     }
 }
コード例 #2
0
ファイル: BotwinExtensions.cs プロジェクト: poke/Carter
        private static void ApplyGlobalBeforeHook(IApplicationBuilder builder, BotwinOptions options)
        {
            if (options?.Before != null)
            {
                builder.Use(async(ctx, next) =>
                {
                    var loggerFactory = ctx.RequestServices.GetService <ILoggerFactory>();
                    var logger        = loggerFactory.CreateLogger("Botwin.GlobalBeforeHook");
                    logger.LogTrace("Executing global before hook");

                    var carryOn = await options.Before(ctx);
                    if (carryOn)
                    {
                        logger.LogTrace("Executing next handler after global before hook");
                        await next();
                    }
                });
            }
        }