Add API listen port configuration
This commit is contained in:
		
							
								
								
									
										7
									
								
								PluralKit.API/ApiConfig.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										7
									
								
								PluralKit.API/ApiConfig.cs
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,7 @@ | |||||||
|  | namespace PluralKit.API | ||||||
|  | { | ||||||
|  |     public class ApiConfig | ||||||
|  |     { | ||||||
|  |         public int Port { get; set; } = 5000; | ||||||
|  |     } | ||||||
|  | } | ||||||
| @@ -25,6 +25,7 @@ | |||||||
|       <PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="3.1.0" /> |       <PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="3.1.0" /> | ||||||
|       <PackageReference Include="Microsoft.AspNetCore.Mvc.Versioning" Version="4.1.1" /> |       <PackageReference Include="Microsoft.AspNetCore.Mvc.Versioning" Version="4.1.1" /> | ||||||
|       <PackageReference Include="Microsoft.AspNetCore.Mvc.Versioning.ApiExplorer" Version="4.1.1" /> |       <PackageReference Include="Microsoft.AspNetCore.Mvc.Versioning.ApiExplorer" Version="4.1.1" /> | ||||||
|  |       <PackageReference Include="Serilog.AspNetCore" Version="3.4.0" /> | ||||||
|       <PackageReference Include="Swashbuckle.AspNetCore.Annotations" Version="5.4.1" /> |       <PackageReference Include="Swashbuckle.AspNetCore.Annotations" Version="5.4.1" /> | ||||||
|       <PackageReference Include="Swashbuckle.AspNetCore.Filters" Version="5.1.1" /> |       <PackageReference Include="Swashbuckle.AspNetCore.Filters" Version="5.1.1" /> | ||||||
|       <PackageReference Include="Swashbuckle.AspNetCore.Newtonsoft" Version="5.4.1" /> |       <PackageReference Include="Swashbuckle.AspNetCore.Newtonsoft" Version="5.4.1" /> | ||||||
|   | |||||||
| @@ -1,6 +1,7 @@ | |||||||
| using Autofac.Extensions.DependencyInjection; | using Autofac.Extensions.DependencyInjection; | ||||||
|  |  | ||||||
| using Microsoft.AspNetCore.Hosting; | using Microsoft.AspNetCore.Hosting; | ||||||
|  | using Microsoft.Extensions.DependencyInjection; | ||||||
| using Microsoft.Extensions.Hosting; | using Microsoft.Extensions.Hosting; | ||||||
|  |  | ||||||
| using PluralKit.Core; | using PluralKit.Core; | ||||||
| @@ -21,7 +22,10 @@ namespace PluralKit.API | |||||||
|                 .ConfigureWebHostDefaults(whb => whb |                 .ConfigureWebHostDefaults(whb => whb | ||||||
|  |  | ||||||
|                     .UseConfiguration(InitUtils.BuildConfiguration(args).Build()) |                     .UseConfiguration(InitUtils.BuildConfiguration(args).Build()) | ||||||
|                     .ConfigureKestrel(opts => { opts.ListenAnyIP(5000); }) |                     .ConfigureKestrel(opts => | ||||||
|  |                     { | ||||||
|  |                         opts.ListenAnyIP(opts.ApplicationServices.GetRequiredService<ApiConfig>().Port); | ||||||
|  |                     }) | ||||||
|                     .UseStartup<Startup>()); |                     .UseStartup<Startup>()); | ||||||
|     } |     } | ||||||
| } | } | ||||||
| @@ -91,7 +91,7 @@ namespace PluralKit.API | |||||||
|         { |         { | ||||||
|             builder.RegisterInstance(InitUtils.BuildConfiguration(Environment.GetCommandLineArgs()).Build()) |             builder.RegisterInstance(InitUtils.BuildConfiguration(Environment.GetCommandLineArgs()).Build()) | ||||||
|                 .As<IConfiguration>(); |                 .As<IConfiguration>(); | ||||||
|             builder.RegisterModule(new ConfigModule<object>()); |             builder.RegisterModule(new ConfigModule<ApiConfig>("API")); | ||||||
|             builder.RegisterModule(new LoggingModule("api")); |             builder.RegisterModule(new LoggingModule("api")); | ||||||
|             builder.RegisterModule(new MetricsModule("API")); |             builder.RegisterModule(new MetricsModule("API")); | ||||||
|             builder.RegisterModule<DataStoreModule>(); |             builder.RegisterModule<DataStoreModule>(); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user