62 lines
2.2 KiB
C#
62 lines
2.2 KiB
C#
using Elsa.Persistence.EntityFramework.Core.Extensions;
|
|
using Elsa.Persistence.EntityFramework.Sqlite;
|
|
using Microsoft.AspNetCore.Builder;
|
|
using Microsoft.AspNetCore.Hosting;
|
|
using Microsoft.Extensions.Configuration;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using Microsoft.Extensions.Hosting;
|
|
|
|
namespace Elsa.Samples.Server.Host
|
|
{
|
|
public class Startup
|
|
{
|
|
public Startup(IWebHostEnvironment environment, IConfiguration configuration)
|
|
{
|
|
Environment = environment;
|
|
Configuration = configuration;
|
|
}
|
|
|
|
private IWebHostEnvironment Environment { get; }
|
|
private IConfiguration Configuration { get; }
|
|
|
|
public void ConfigureServices(IServiceCollection services)
|
|
{
|
|
var elsaSection = Configuration.GetSection("Elsa");
|
|
|
|
services
|
|
.AddElsa(elsa => elsa
|
|
.UseEntityFrameworkPersistence(ef => ef.UseSqlite())
|
|
.AddConsoleActivities()
|
|
.AddHttpActivities(elsaSection.GetSection("Http").Bind)
|
|
.AddEmailActivities(elsaSection.GetSection("Smtp").Bind)
|
|
.AddQuartzTemporalActivities()
|
|
.AddWorkflowsFrom<Startup>()
|
|
);
|
|
|
|
services
|
|
.AddElsaApiEndpoints()
|
|
.AddElsaSwagger();
|
|
|
|
// Allow arbitrary client browser apps to access the API for demo purposes only.
|
|
// In a production environment, make sure to allow only origins you trust.
|
|
services.AddCors(cors => cors.AddDefaultPolicy(policy => policy.AllowAnyHeader().AllowAnyMethod().AllowAnyOrigin().WithExposedHeaders("Content-Disposition")));
|
|
}
|
|
|
|
public void Configure(IApplicationBuilder app)
|
|
{
|
|
if (Environment.IsDevelopment())
|
|
{
|
|
app.UseDeveloperExceptionPage();
|
|
app.UseSwagger();
|
|
app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "Elsa"));
|
|
}
|
|
|
|
app
|
|
.UseCors()
|
|
.UseHttpActivities()
|
|
.UseCors()
|
|
.UseRouting()
|
|
.UseEndpoints(configure => configure.MapControllers());
|
|
}
|
|
}
|
|
} |