Add Caspian.WorkflowFramework & Caspian.WorkflowFramework.Sample + Config these
This commit is contained in:
@@ -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();
|
||||
Reference in New Issue
Block a user