Example #1
0
        /// <summary>
        /// ÅäÖÃ
        /// </summary>
        /// <param name="app"></param>
        /// <param name="env"></param>
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
        {
            var rewriteOptions = new RewriteOptions();

            rewriteOptions.Add(new RedirectHomeIndexRequests("/swagger/index.html"));
            app.UseRewriter(rewriteOptions);
            _webAPIStartupHelper.Configure(app, env);
        }
Example #2
0
        /// <summary>
        /// ÅäÖÃ
        /// </summary>
        /// <param name="app"></param>
        /// <param name="env"></param>
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
        {
            var rewriteOptions = new RewriteOptions();

            rewriteOptions.Add(new RedirectHomeIndexRequests("/swagger/index.html"));
            app.UseRewriter(rewriteOptions);
            _webAPIStartupHelper.Configure(app, env);
            var dbContextHelper = ApplicationData.GetService <DBContextHelper <AuthorityDBContext> >();

            dbContextHelper.Migrate();
            ApplicationData.GetService <IServerHub>();
        }
Example #3
0
        /// <summary>
        /// 配置
        /// </summary>
        /// <param name="app"></param>
        /// <param name="env"></param>
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
        {
            ApplicationData.GetService <ICacheManager>();
            var rewriteOptions = new RewriteOptions();

            rewriteOptions.Add(new RedirectHomeIndexRequests("/swagger/index.html"));
            app.UseRewriter(rewriteOptions);
            _webAPIStartupHelper.Configure(app, env);
            var dbContextHelper = ApplicationData.GetService <DBContextHelper <ConfigCenterEnvironmentDBContext> >();

            dbContextHelper.Migrate();
            Task task = Task.Run(async() =>
            {
                await ConnectConfigCenterAsync();
            });

            Task.WaitAll(task);
        }
Example #4
0
        /// <summary>
        /// ÅäÖÃ
        /// </summary>
        /// <param name="app"></param>
        /// <param name="env"></param>
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
        {
            var rewriteOptions = new RewriteOptions();

            rewriteOptions.Add(new RewriteHomeIndexRequests("/Portal/index.html"));
            app.UseRewriter(rewriteOptions);
            string basePath = AppDomain.CurrentDomain.BaseDirectory ?? string.Empty;
            string path     = Path.Combine(basePath, "Application");

            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
            }
            app.Use(async(httpContext, next) =>
            {
                if (httpContext.Request.Path.HasValue)
                {
                    if (DeployConfig.ApplicationNameWhiteList.Any(item => httpContext.Request.Path.Value.StartsWith($"/{item}")))
                    {
                        await next();
                    }
                    else
                    {
                        var applicationInfoService = ApplicationData.GetService <IApplicationInfoService>();
                        string[] paths             = httpContext.Request.Path.Value.Split("/");
                        if (paths.Length >= 2 && applicationInfoService.IsRuningApplication(paths[1]))
                        {
                            await next();
                        }
                        else
                        {
                            httpContext.Response.StatusCode = StatusCodes.Status404NotFound;
                        }
                    }
                }
            });

            var provider = new FileExtensionContentTypeProvider();

            provider.Mappings[".json"]  = "application/json";
            provider.Mappings[".woff"]  = "application/font-woff";
            provider.Mappings[".woff2"] = "application/font-woff";
            app.UseStaticFiles(new StaticFileOptions
            {
                FileProvider      = new PhysicalFileProvider(path),
                OnPrepareResponse = context =>
                {
                    context.Context.Response.Headers.Add("Access-Control-Allow-Methods", "*");
                    context.Context.Response.Headers.Add("Access-Control-Allow-Origin", "*");
                    context.Context.Response.Headers.Add("Access-Control-Allow-Headers", "*");
                },
                RequestPath           = "",
                ContentTypeProvider   = provider,
                ServeUnknownFileTypes = true,
                DefaultContentType    = "application/octet-stream"
            });
            _webAPIStartupHelper.Configure(app, env);
            var dbContextHelper = ApplicationData.GetService <DBContextHelper <DeployDBContext> >();

            dbContextHelper.Migrate();
            ApplicationData.GetService <IServerHub>();
        }