-
Notifications
You must be signed in to change notification settings - Fork 84
Expand file tree
/
Copy pathProgram.cs
More file actions
48 lines (38 loc) · 1.63 KB
/
Program.cs
File metadata and controls
48 lines (38 loc) · 1.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using DevProxy;
using DevProxy.Commands;
using System.Net;
static WebApplication BuildApplication(string[] args, DevProxyConfigOptions options)
{
var builder = WebApplication.CreateBuilder(args);
_ = builder.Configuration.ConfigureDevProxyConfig(options);
_ = builder.Logging.ConfigureDevProxyLogging(builder.Configuration, options);
_ = builder.Services.ConfigureDevProxyServices(builder.Configuration, options);
var defaultIpAddress = "127.0.0.1";
var ipAddress = options.IPAddress ??
builder.Configuration.GetValue("ipAddress", defaultIpAddress) ??
defaultIpAddress;
var defaultApiPort = 8897;
var apiPort = options.ApiPort ??
builder.Configuration.GetValue("apiPort", defaultApiPort);
_ = builder.WebHost.ConfigureKestrel(options =>
{
options.Listen(IPAddress.Parse(ipAddress), apiPort);
});
var app = builder.Build();
_ = app.UseSwagger();
_ = app.UseSwaggerUI();
_ = app.MapControllers();
return app;
}
_ = Announcement.ShowAsync();
var options = new DevProxyConfigOptions();
options.ParseOptions(args);
var app = BuildApplication(args, options);
var devProxyCommand = app.Services.GetRequiredService<DevProxyCommand>();
var loggerFactory = app.Services.GetRequiredService<ILoggerFactory>();
var exitCode = await devProxyCommand.InvokeAsync(args, app);
loggerFactory.Dispose();
Environment.Exit(exitCode);