Add Caspian.WorkflowFramework & Caspian.WorkflowFramework.Sample + Config these

This commit is contained in:
2025-08-19 18:26:51 +03:30
parent b626db299c
commit dfe36b55a0
33 changed files with 2562 additions and 194 deletions
@@ -0,0 +1,78 @@
using Caspian.WorkflowFramework;
using Caspian.WorkflowFramework.Sample;
using Microsoft.OpenApi.Models;
using San.MongoLogger;
using San.MongoLogger.Models;
using Parlot.Fluent;
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
builder.Services.AddCors(options =>
{
options.AddPolicy("AllowSpecificOrigin",
builder => builder.AllowAnyOrigin() // Add your client origin
.AllowAnyMethod() // Allow any HTTP method
.AllowAnyHeader()); // Allow any header
});
builder.Services.AddControllers();
// Learn more about configuring OpenAPI at https://aka.ms/aspnet/openapi
//builder.Services.AddOpenApi();
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen(c =>
{
c.SwaggerDoc("v1", new OpenApiInfo { Title = "My API", Version = "v1" });
c.DocumentFilter<ExcludeExternalControllersFilter>();
c.CustomSchemaIds(type => type.FullName);
});
//Workflow
//var connectionString = builder.Configuration.GetConnectionString("DefaultConnection");
var t = $"appsettings.workflow.{builder.Environment.EnvironmentName}.json";
builder.AddWorkflowFramework($"appsettings.workflow.json");
builder.Services.AddMongoLogger<LogModel>(builder.Configuration);
var app = builder.Build();
app.UseMongoLogger<LogModel>();
// Enable CORS before authentication and authorization
app.UseCors("AllowSpecificOrigin");
// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
//app.MapOpenApi();
app.UseSwagger();
app.UseSwaggerUI(c =>
{
c.SwaggerEndpoint("/swagger/v1/swagger.json", "My API V1");
c.RoutePrefix = string.Empty; // Set Swagger UI at the app's root URL
});
}
app.UseAuthorization();
app.MapControllers();
//Workflow
app.UseWorkflowFramework();
// Redirect to Swagger URL
app.Use(async (context, next) =>
{
// Check if current request is the root URL ("/")
if (context.Request.Path == "/")
{
// Redirect to Swagger UI
context.Response.Redirect("/swagger/index.html");
return;
}
await next(); // Proceed to the next middleware if not redirecting
});
app.Run();