Esempio n. 1
0
        public Startup(IWebHostEnvironment env, IConfiguration configuration) : base(env, configuration)
        {
            RegisterValidators.Add(typeof(IValidator));

            BeforeConfigureServices = services =>
            {
                // Setting

                SystemSetting.Current = Configuration.GetSection <SystemSetting>("Setting");

                // Database

                services.AddGoblinDbContext();

                // Directory Browser

                if (SystemSetting.Current.IsEnableDictionaryBrowser)
                {
                    services.AddDirectoryBrowser();
                }
            };

            BeforeConfigureApp = (app, environment, lifetime) =>
            {
                var resourceFolderPathAbsolute = PathHelper.GetFullPath(SystemSetting.Current.ResourceFolderPath);

                DirectoryHelper.CreateIfNotExist(resourceFolderPathAbsolute);

                // Static Files

                app.UseStaticFiles(new StaticFileOptions
                {
                    FileProvider = new PhysicalFileProvider(resourceFolderPathAbsolute),

                    RequestPath = new PathString(SystemSetting.Current.ResourceFolderEndpoint)
                });

                // Directory Browser

                if (SystemSetting.Current.IsEnableDictionaryBrowser)
                {
                    app.UseDirectoryBrowser(new DirectoryBrowserOptions
                    {
                        FileProvider = new PhysicalFileProvider(resourceFolderPathAbsolute),
                        RequestPath  = new PathString(SystemSetting.Current.ResourceFolderEndpoint)
                    });
                }
            };
        }
Esempio n. 2
0
        public Startup(IWebHostEnvironment env, IConfiguration configuration) : base(env, configuration)
        {
            RegisterValidators.Add(typeof(IValidator));

            BeforeConfigureServices = services =>
            {
                // Setting

                SystemSetting.Current = Configuration.GetSection <SystemSetting>("Setting");

                // Database

                services.AddGoblinDbContext();
            };
        }
Esempio n. 3
0
        public Startup(IWebHostEnvironment env, IConfiguration configuration) : base(env, configuration)
        {
            RegisterValidators.Add(typeof(IValidator));
            RegisterValidators.Add(typeof(BlogCrawler.Share.Validators.IValidator));
            RegisterValidators.Add(typeof(Identity.Share.Validators.IValidator));
            RegisterValidators.Add(typeof(Notification.Share.Validators.IValidator));

            BeforeConfigureServices = services =>
            {
                // Setting

                SystemSetting.Current = Configuration.GetSection <SystemSetting>("Setting");

                // Blog Crawler Service

                GoblinBlogCrawlerHelper.Domain = SystemSetting.Current.BlogCrawlerServiceDomain;

                GoblinBlogCrawlerHelper.AuthorizationKey = SystemSetting.Current.BlogCrawlerServiceAuthorizationKey;

                // Identity Service

                GoblinIdentityHelper.Domain = SystemSetting.Current.IdentityServiceDomain;

                GoblinIdentityHelper.AuthorizationKey = SystemSetting.Current.IdentityServiceAuthorizationKey;

                // Notification Service

                GoblinNotificationHelper.Domain = SystemSetting.Current.NotificationServiceDomain;

                GoblinNotificationHelper.AuthorizationKey = SystemSetting.Current.NotificationServiceAuthorizationKey;

                // Resource Service

                GoblinResourceHelper.Domain = SystemSetting.Current.ResourceServiceDomain;

                GoblinResourceHelper.AuthorizationKey = SystemSetting.Current.ResourceServiceAuthorizationKey;
            };

            BeforeUseMvc = (app, env, lifetime) =>
            {
                app.UseStatusCodePagesWithReExecute("/error/{0}");
            };
        }