elsa-core/src/samples/server/Elsa.Samples.Server.Host/Startup.cs
Craig Fowler ed81b5679a WIP #564 - Rename & alter temporal activity setup
Temporal activities no longer have a generalised extension method
for registering them with a service collecton.  It is still static and has
the same rough shape as an extension method.  This way it is less
visible and less likely to be called by accident.

Also in-line with changes in this branch, things have been renamed
  Timers → Temporal
2021-02-28 20:49:34 +01:00

61 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()));
}
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()
.UseRouting()
.UseEndpoints(configure => configure.MapControllers());
}
}
}