Esempio n. 1
0
        /// <summary>
        /// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        /// </summary>
        /// <param name="app"></param>
        /// <param name="configLogic"></param>
        public void Configure(IApplicationBuilder app, IConfigLogic configLogic)
        {
            // Refresh global config
            configLogic.Refresh();

            // Add SecureHeadersMiddleware to the pipeline
            app.UseSecureHeadersMiddleware(_configuration.Get <SecureHeadersMiddlewareConfiguration>());

            app.UseCors("CorsPolicy");

            if (_env.IsDevelopment())
            {
                app.UseDatabaseErrorPage();

                // Enable middleware to serve generated Swagger as a JSON endpoint.
                app.UseSwagger();

                // Enable middleware to serve swagger-ui (HTML, JS, CSS, etc.),
                // specifying the Swagger JSON endpoint.
                app.UseSwaggerUI(c => { c.SwaggerEndpoint("/swagger/v1/swagger.json", "My API V1"); });
            }
            else
            {
                app.UseWebMarkupMin();
            }

            // Not necessary for this workshop but useful when running behind kubernetes
            app.UseForwardedHeaders(new ForwardedHeadersOptions
            {
                // Read and use headers coming from reverse proxy: X-Forwarded-For X-Forwarded-Proto
                // This is particularly important so that HttpContent.Request.Scheme will be correct behind a SSL terminating proxy
                ForwardedHeaders = ForwardedHeaders.XForwardedFor |
                                   ForwardedHeaders.XForwardedProto
            });

            app.Use(async(context, next) =>
            {
                await next();

                if (context.Response.IsFailure())
                {
                    context.Request.Path = $"/Error/{context.Response.StatusCode}";
                    await next();
                }
            });


            // Use wwwroot folder as default static path
            app.UseDefaultFiles()
            .UseStaticFiles()
            .UseCookiePolicy()
            .UseSession()
            .UseRouting()
            .UseAuthentication()
            .UseAuthorization()
            .UseEndpoints(endpoints => endpoints.MapControllers());

            Console.WriteLine("Application Started!");
        }
        /// <summary>
        /// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        /// </summary>
        /// <param name="app"></param>
        /// <param name="configLogic"></param>
        /// <param name="streamRipperManager"></param>
        /// <param name="shoutcastDirectoryApi"></param>
        public void Configure(IApplicationBuilder app, IConfigLogic configLogic, IStreamRipperManager streamRipperManager, IShoutcastDirectoryApi shoutcastDirectoryApi)
        {
            configLogic.Refresh().Wait();

            streamRipperManager.Refresh().Wait();

            shoutcastDirectoryApi.Setup();

            app.UseMiniProfiler();

            app.UseCors("CorsPolicy");

            app.UseResponseCompression();

            if (_env.IsDevelopment())
            {
                app.UseDatabaseErrorPage();

                // Enable middleware to serve generated Swagger as a JSON endpoint.
                app.UseSwagger();

                // Enable middleware to serve swagger-ui (HTML, JS, CSS, etc.),
                // specifying the Swagger JSON endpoint.
                app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "My API V1"));
            }

            // Not necessary for this workshop but useful when running behind kubernetes
            app.UseForwardedHeaders(new ForwardedHeadersOptions
            {
                // Read and use headers coming from reverse proxy: X-Forwarded-For X-Forwarded-Proto
                // This is particularly important so that HttpContent.Request.Scheme will be correct behind a SSL terminating proxy
                ForwardedHeaders = ForwardedHeaders.XForwardedFor |
                                   ForwardedHeaders.XForwardedProto
            });

            // Use wwwroot folder as default static path
            app.UseDefaultFiles()
            .UseStaticFiles()
            .UseCookiePolicy()
            .UseSession()
            .UseRouting()
            .UseCors("CorsPolicy")
            .UseAuthentication()
            .UseAuthorization()
            .UseEndpoints(endpoints =>
            {
                endpoints.MapDefaultControllerRoute();

                endpoints.MapHub <MessageHub>("/hub");
            });

            Console.WriteLine("Application Started!");
        }
Esempio n. 3
0
 public SendProcessLogic(IPushProcessHistoryService pushProcessHistoryService
                         , IMapper mapper
                         , IConfigLogic configLogic
                         , IPushSendProcessService pushSendProcessService
                         , IChannelLogic channelLogic
                         , ITokenBrandLogic tokenBrandLogic
                         )
 {
     _pushProcessHistoryService = pushProcessHistoryService;
     _mapper                 = mapper;
     _configLogic            = configLogic;
     _pushSendProcessService = pushSendProcessService;
     _channelLogic           = channelLogic;
     _tokenBrandLogic        = tokenBrandLogic;
 }
Esempio n. 4
0
 /// <summary>
 /// Constructor dependency injection
 /// </summary>
 /// <param name="state"></param>
 /// <param name="streamLogic"></param>
 /// <param name="sinkService"></param>
 /// <param name="hub"></param>
 /// <param name="configLogic"></param>
 /// <param name="filterSongLogic"></param>
 /// <param name="streamRipperProxy"></param>
 /// <param name="songMetaDataExtract"></param>
 /// <param name="logger"></param>
 public StreamRipperManager(StreamRipperState state, IStreamLogic streamLogic, ISinkService sinkService,
                            IHubContext <MessageHub> hub, IConfigLogic configLogic, IFilterSongLogic filterSongLogic,
                            IStreamRipperProxy streamRipperProxy,
                            ISongMetaDataExtract songMetaDataExtract, ILogger <IStreamRipper> logger)
 {
     _state               = state;
     _streamLogic         = streamLogic;
     _sinkService         = sinkService;
     _hub                 = hub;
     _configLogic         = configLogic;
     _filterSongLogic     = filterSongLogic;
     _songMetaDataExtract = songMetaDataExtract;
     _streamRipperProxy   = streamRipperProxy;
     _logger              = logger;
 }
Esempio n. 5
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env, IConfigLogic configLogic)
        {
            configLogic.Cleanup().Wait();

            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            app.UseCors("CorsPolicy");

            // Enable middleware to serve generated Swagger as a JSON endpoint.
            app.UseSwagger();

            // Enable middleware to serve swagger-ui (HTML, JS, CSS, etc.),
            // specifying the Swagger JSON endpoint.
            app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "V1"));

            app.UseRouting()
            .UseEndpoints(endpoint => endpoint.MapDefaultControllerRoute());
        }
Esempio n. 6
0
        //private ILoggerFactory _loggerFactory;

        public MsgService(IConfigLogic configLogic
                          , IMapper mapper
                          , ITokenBrandLogic tokenBrandLogic
                          , IPushTokenBrandService pushTokenBrandService
                          , ISendProcessLogic sendProcessLogic
                          , IPushSendProcessService pushSendProcessService
                          , IEventNotification eventNotification
                          //, ILoggerFactory loggerFactory
                          )
        {
            _configLogic            = configLogic;
            _mapper                 = mapper;
            _tokenBrandLogic        = tokenBrandLogic;
            _pushTokenBrandService  = pushTokenBrandService;
            _sendProcessLogic       = sendProcessLogic;
            _pushSendProcessService = pushSendProcessService;
            _eventNotification      = eventNotification;
            //_loggerFactory = loggerFactory;
            //初始化信号量
            InitSemaphore();
            //初始化队列
            InitQueue();
        }
Esempio n. 7
0
 public ConfigController(IConfigLogic configLogic)
 {
     _configLogic = configLogic;
 }
Esempio n. 8
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env, IConfigLogic configLogic, IEfRepository repository)
        {
            var dal = repository.For <User>().Session();

            foreach (var user in dal.GetAll().Result)
            {
                user.UserNotifications = new List <UserNotification>
                {
                    new UserNotification
                    {
                        Subject   = "Welcome Back",
                        Text      = "Thanks for coming back to Anahita.dev.",
                        Collected = false,
                        DateTime  = DateTimeOffset.Now
                    }
                };

                dal.Update(user.Id, user).Wait();
            }

            dal.Dispose();

            if (!env.IsDevelopment())
            {
                // Refresh global config
                configLogic.Refresh();
            }

            app.UseResponseCompression();

            if (_env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                app.UseBrowserLink();

                // Enable middleware to serve generated Swagger as a JSON endpoint.
                app.UseSwagger();

                // Enable middleware to serve swagger-ui (HTML, JS, CSS, etc.),
                // specifying the Swagger JSON endpoint.
                app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "My API V1"));
            }
            else
            {
                app.UseWebMarkupMin();
            }

            // Not necessary for this workshop but useful when running behind kubernetes
            app.UseForwardedHeaders(new ForwardedHeadersOptions
            {
                // Read and use headers coming from reverse proxy: X-Forwarded-For X-Forwarded-Proto
                // This is particularly important so that HttpContent.Request.Scheme will be correct behind a SSL terminating proxy
                ForwardedHeaders = ForwardedHeaders.XForwardedFor |
                                   ForwardedHeaders.XForwardedProto
            });

            app.Use(async(context, next) =>
            {
                await next();
                if (context.Response.StatusCode == 404)
                {
                    context.Request.Path = "/error/404";
                    await next();
                }
            });

            // Use wwwroot folder as default static path
            app.UseDefaultFiles()
            .UseStaticFiles()
            .UseCookiePolicy()
            .UseSession()
            .UseRouting()
            .UseCors("CorsPolicy")
            .UseAuthentication()
            .UseAuthorization()
            .UseEndpoints(endpoints => { endpoints.MapDefaultControllerRoute(); });

            Console.WriteLine("Application Started!");
        }