コード例 #1
0
        public Task Invoke(HttpContext context, IAbstractItemStorageProvider provider)
        {
            CancellationToken cancellationToken = context?.RequestAborted ?? CancellationToken.None;

            AbstractItemStorage abstractItems = provider.Get();

            if (cancellationToken.IsCancellationRequested)
            {
                return(Task.CompletedTask);
            }

            var startPage = abstractItems
                            .GetStartPage(context.Request.Host.Value, _filterAccessor?.Get());

            if (startPage is null)
            {
                throw new StartPageNotFoundException(context.Request.Host.Value);
            }

            context.Items[RoutingKeys.StartPage]           = startPage;
            context.Items[RoutingKeys.AbstractItemStorage] = abstractItems;

            // Call the next delegate/middleware in the pipeline
            return(_next(context));
        }
コード例 #2
0
 public TextPageController(IAbstractItemStorageProvider abstractItemProvider, ILogger <TextPageController> logger)
 {
     _provider = abstractItemProvider.Get();
     _logger   = logger;
 }