Merge branch 'feature/com-control-base-path' into 'main'
added base path to communication control See merge request kzotkin/hiveemulator!7
This commit is contained in:
		
						commit
						f1d8b95744
					
				@ -19,6 +19,8 @@ internal class Program
 | 
				
			|||||||
        // TODO: consider this approach
 | 
					        // TODO: consider this approach
 | 
				
			||||||
        builder.Services.AddJsonControllerOptionsConfiguration();
 | 
					        builder.Services.AddJsonControllerOptionsConfiguration();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        string basePath = builder.Configuration.GetValue<string>("BasePath") ?? string.Empty;
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
        builder.Services.AddEndpointsApiExplorer();
 | 
					        builder.Services.AddEndpointsApiExplorer();
 | 
				
			||||||
        builder.Services.AddSwaggerGen(c =>
 | 
					        builder.Services.AddSwaggerGen(c =>
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
@ -41,13 +43,26 @@ internal class Program
 | 
				
			|||||||
        builder.Services.AddProblemDetails();
 | 
					        builder.Services.AddProblemDetails();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        var app = builder.Build();
 | 
					        var app = builder.Build();
 | 
				
			||||||
 | 
					        if (!string.IsNullOrEmpty(basePath))
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            var pathBase = new PathString(basePath);
 | 
				
			||||||
 | 
					            app.UsePathBase(pathBase);
 | 
				
			||||||
 | 
					            app.Use(async (context, next) =>
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                context.Request.PathBase = pathBase;
 | 
				
			||||||
 | 
					                await next();
 | 
				
			||||||
 | 
					            });
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
        
 | 
					        
 | 
				
			||||||
        app.UseExceptionHandler();
 | 
					        app.UseExceptionHandler();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        
 | 
					 | 
				
			||||||
        app.UseSwagger();
 | 
					        app.UseSwagger();
 | 
				
			||||||
        app.UseSwaggerUI();
 | 
					        app.UseSwaggerUI(c =>
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            c.SwaggerEndpoint($"{basePath}/swagger/v1/swagger.json", "CommunicationControl - V1");
 | 
				
			||||||
 | 
					            c.RoutePrefix = $"swagger";
 | 
				
			||||||
            
 | 
					            
 | 
				
			||||||
 | 
					        });
 | 
				
			||||||
        app.UseCors(corsPolicyName);
 | 
					        app.UseCors(corsPolicyName);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        app.UseAuthorization();
 | 
					        app.UseAuthorization();
 | 
				
			||||||
 | 
				
			|||||||
@ -20,6 +20,7 @@
 | 
				
			|||||||
  },
 | 
					  },
 | 
				
			||||||
  "AllowedHosts": "*",
 | 
					  "AllowedHosts": "*",
 | 
				
			||||||
  "Urls": "http://0.0.0.0:8080",
 | 
					  "Urls": "http://0.0.0.0:8080",
 | 
				
			||||||
 | 
					  "BasePath": "/",
 | 
				
			||||||
  "Serilog": {
 | 
					  "Serilog": {
 | 
				
			||||||
    "Using": [ "Serilog.Sinks.Console", "Serilog.Sinks.File" ],
 | 
					    "Using": [ "Serilog.Sinks.Console", "Serilog.Sinks.File" ],
 | 
				
			||||||
    "MinimumLevel": {
 | 
					    "MinimumLevel": {
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user