public ShoutcastDirectoryController(IShoutcastDirectoryApi shoutcastDirectoryApi)
 {
     _shoutcastDirectoryApi = shoutcastDirectoryApi;
 }
Ejemplo n.º 2
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>
        /// <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!");
        }