File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ namespace WebApi . Options ;
2+
3+ /// <summary>
4+ /// Hosting Options
5+ /// </summary>
6+ public class HostingOptions
7+ {
8+ /// <summary>
9+ /// Enable the HTTPS redirection middleware.
10+ /// </summary>
11+ public bool EnableHttpsRedirect { get ; set ; } = true ;
12+ }
Original file line number Diff line number Diff line change 99using Microsoft . AspNetCore . Mvc ;
1010using Microsoft . Data . Sqlite ;
1111using Microsoft . Extensions . Configuration . AzureAppConfiguration ;
12+ using Microsoft . Extensions . Options ;
1213using SnooBrowser . Extensions . DependencyInjection ;
1314using Swashbuckle . AspNetCore . SwaggerUI ;
1415using WebApi . AuthHandlers ;
1516using WebApi . Middleware ;
1617using WebApi . Models . Swagger ;
18+ using WebApi . Options ;
1719
1820var builder = WebApplication . CreateBuilder ( args ) ;
1921
8587
8688app . UseStaticFiles ( ) ;
8789
88- app . UseHttpsRedirection ( ) ;
90+ var hostingOptions = app . Services . GetRequiredService < IOptions < HostingOptions > > ( ) ;
91+
92+ if ( hostingOptions . Value . EnableHttpsRedirect )
93+ app . UseHttpsRedirection ( ) ;
8994
9095app . UseJsonExceptionHandler ( ) ;
9196
You can’t perform that action at this time.
0 commit comments