Files
EonaCat.DoxaApi/sample/SampleApi/Program.cs
T
2026-06-21 20:10:02 +02:00

35 lines
1.1 KiB
C#

using EonaCat.DoxaApi;
using EonaCat.DoxaApi.Middleware;
var builder = WebApplication.CreateBuilder(args);
// This file is part of the EonaCat project(s) which is released under the Apache License.
// See the LICENSE file or go to https://EonaCat.com/license for full license details.
builder.Services.AddControllers();
builder.Services.AddDoxaApi(options =>
{
options.Title = "Sample API";
options.Description = "A demo service showing off the DoxaApi UI - users and orders.";
options.Version = "v1";
options.AccentColor = "#6366f1";
// Declare how clients authenticate; DoxaApi auto-detects which endpoints
// require it via [Authorize] / [DoxaApiAuth] and renders an Authorize dialog.
options.AddBearerAuth(description: "Paste a JWT issued by /api/auth/login.");
options.AddApiKeyAuth("apiKey", "X-API-Key", description: "A static key for service-to-service calls.");
options.DefaultSecurityScheme = "bearer";
});
var app = builder.Build();
app.UseRouting();
app.UseDoxaApi(options =>
{
options.RoutePrefix = "doxa";
});
app.MapControllers();
app.MapGet("/", () => Results.Redirect("/doxa"));
app.Run();