mirror of
https://github.com/xljiulang/KestrelApp.git
synced 2026-10-18 13:10:45 +08:00
42 lines
1.3 KiB
C#
42 lines
1.3 KiB
C#
using Microsoft.AspNetCore.Builder;
|
|
using Microsoft.AspNetCore.Hosting;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using Serilog;
|
|
|
|
namespace KestrelApp.Fiddler
|
|
{
|
|
public class Program
|
|
{
|
|
public static void Main(string[] args)
|
|
{
|
|
var builder = WebApplication.CreateBuilder(args);
|
|
|
|
builder.Services
|
|
.AddFiddler()
|
|
.AddControllers();
|
|
|
|
builder.Host.UseSerilog((hosting, logger) =>
|
|
{
|
|
logger.ReadFrom
|
|
.Configuration(hosting.Configuration)
|
|
.Enrich.FromLogContext().WriteTo.Console(outputTemplate: "{Timestamp:O} [{Level:u3}]{NewLine}{SourceContext}{NewLine}{Message:lj}{NewLine}{Exception}{NewLine}");
|
|
});
|
|
|
|
builder.WebHost.ConfigureKestrel((context, kestrel) =>
|
|
{
|
|
var section = context.Configuration.GetSection("Kestrel");
|
|
kestrel.Configure(section).Endpoint("Fiddler", endpoint => endpoint.ListenOptions.UseFiddler());
|
|
});
|
|
|
|
var app = builder.Build();
|
|
app.UseRouting();
|
|
app.UseFiddler();
|
|
|
|
app.MapControllerRoute(
|
|
name: "default",
|
|
pattern: "{controller=Home}/{action=Index}/{id?}");
|
|
|
|
app.Run();
|
|
}
|
|
}
|
|
} |