mirror of
https://github.com/DorkSquadRR/DorkNet.git
synced 2026-10-26 07:28:45 -07:00
Add microservices scaffold
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
using DorkNet.Contracts;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
|
||||
namespace DorkNet.ServiceDefaults;
|
||||
|
||||
public static class DorkNetServiceDefaultsExtensions
|
||||
{
|
||||
public static WebApplicationBuilder AddDorkNetServiceDefaults(
|
||||
this WebApplicationBuilder builder,
|
||||
string serviceName)
|
||||
{
|
||||
builder.Services.AddSingleton(new DorkNetServiceInfo(serviceName));
|
||||
builder.Services.AddHealthChecks();
|
||||
builder.Services.AddHttpClient();
|
||||
builder.Services.ConfigureHttpJsonOptions(opt =>
|
||||
opt.SerializerOptions.PropertyNamingPolicy = null);
|
||||
|
||||
return builder;
|
||||
}
|
||||
|
||||
public static WebApplication MapDorkNetServiceDefaults(this WebApplication app)
|
||||
{
|
||||
app.MapHealthChecks("/healthz");
|
||||
app.MapGet("/internal/healthz", (DorkNetServiceInfo info) =>
|
||||
{
|
||||
return Results.Ok(new ServiceHealthResponse(
|
||||
info.Name,
|
||||
"ok",
|
||||
DateTimeOffset.UtcNow));
|
||||
});
|
||||
|
||||
return app;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user