Beispiel #1
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public static void Configure(IApplicationBuilder app, IWebHostEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            app.UseSwagger();
            app.UseSwaggerUI(c =>
            {
                c.SwaggerEndpoint("/swagger/v1/swagger.json", "TtsApi v1");

                //Disable the "Try it out" button
                //c.SupportedSubmitMethods(Array.Empty<SubmitMethod>());

                //This garbage doesn't work and therefore the authorization is lost after every reload.
                //Making swagger completely useless for this project.
                //c.ConfigObject.AdditionalItems.Add("persistAuthorization", "true");
            });

            app.UseExceptionHandler(appErr =>
                                    appErr.Run(context =>
            {
                context.Response.StatusCode            = 500;
                IExceptionHandlerPathFeature exception = context.Features.Get <IExceptionHandlerPathFeature>();
                DiscordLogger.LogException(exception.Error);
                return(null);
            }
                                               )
                                    );

            //app.UseHttpsRedirection(); //This breaks UseCors

            app.UseWebSockets();
            app.UseCors();
            app.UseRouting();
            app.UseAuthentication();
            app.UseAuthorization();
            app.UseEndpoints(endpoints =>
            {
                endpoints.MapHub <TtsHub>("/TtsHub", options =>
                {
                    // Not sure if we even need this
                    // options.ApplicationMaxBufferSize = 30 * 1024; // * 1000;
                });
            });
            app.UseEndpoints(endpoints => { endpoints.MapControllers(); });
        }