Perigee With .NET Hosting
Last updated
using Perigee;
using Serilog;
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
builder.Services.AddSingleton(ThreadRegistry.Instance);
builder.Host.UseSerilog();
//Controllers
builder.Services.AddControllers();
//SwaggerGen - https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer().AddSwaggerGen();
//Build / configure
var app = builder.Build();
if (app.Environment.IsDevelopment()) app.UseSwagger().UseSwaggerUI();
// HTTPS/Auth/Controllers/Cors
app.UseHttpsRedirection().UseAuthorization();
app.MapControllers();
app.UseCors(o => o.AllowAnyOrigin().AllowAnyMethod().AllowAnyHeader());
app.UseSerilogRequestLogging();
//Run async!
var taskRunner = app.RunAsync();
//Pass the taskRunner to Perigee initialization
PerigeeApplication.ApplicationNoInit("Hosted Perigee App", (c) => {
//Add and configure away
//Sample running config
c.AddRecurring("Running", (c, l) => { l.LogInformation("I'm running"); });
}, HostTask: taskRunner);
/*********************************************************************/
// TODO:
// Using the package manager console, or the Nuget GUI: install-package Perigee
// Add AppSettings.json and set the "Copy To Output Directory" in the Properties inspector to "Copy Always"
/*********************************************************************/{
"ConnectionStrings": {
},
"AppSettings": {
},
"Perigee": { "HideConsole": false },
"Serilog": {
"MinimumLevel": {
"Default": "Information",
"Override": {
"Microsoft": "Warning",
"System": "Warning",
"Microsoft.AspNetCore": "Warning"
}
},
"WriteTo": [
{ "Name": "Console" }
]
},
"AllowedHosts": "*"
}