예제 #1
0
        public async Task Invoke(HttpContext context)
        {
            var tenantContext = HttpContextExtensions.GetTenant(context);

            if (tenantContext != null)
            {
                //remove the prefix portion of the path
                var originalPath = context.Request.Path;
                _logger.LogInformation($"Original path {originalPath}");
                var tenantFolder = tenantContext.Uuid.ToString();
                _logger.LogInformation($"Tenant Folder {tenantFolder}");
                var paths = context.Request.Path.ToString().Split('/').ToList();
                if (paths.Any())
                {
                    paths.RemoveAt(0);
                    paths.RemoveAt(0);
                }
                var filePath = string.Join <string>('/', paths);
                _logger.LogInformation($"New filePath {filePath}");
                var newPath = new PathString($"/tenantfiles/{tenantFolder}/{filePath}");
                _logger.LogInformation($"NewPath {newPath}");
                context.Request.Path = newPath;

                if (_next != null)
                {
                    await _next(context);
                }

                //replace the original url after the remaining middleware has finished processing
                context.Request.Path = originalPath;
            }
        }
        public void PopulateValues(ViewLocationExpanderContext context)
        {
            var theme = HttpContextExtensions.GetTenant(context.ActionContext.HttpContext)?.Theme ?? "Default";

            context.Values[StaticValues.ThemeKey] = theme;
        }