46 lines
1.4 KiB
C#
46 lines
1.4 KiB
C#
using System.Net.Http.Headers;
|
|
using Elsa.EntityFrameworkCore.Common;
|
|
using Elsa.Samples.AspNet.Onboarding.Web.Data;
|
|
using Elsa.Samples.AspNet.Onboarding.Web.Services;
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
var builder = WebApplication.CreateBuilder(args);
|
|
var services = builder.Services;
|
|
var configuration = builder.Configuration;
|
|
|
|
// Add services to the container.
|
|
services.AddControllersWithViews();
|
|
services.AddDbContextFactory<OnboardingDbContext>(options => options.UseSqlite("Data Source=onboarding.db"));
|
|
services.AddHostedService<RunMigrationsHostedService<OnboardingDbContext>>();
|
|
|
|
// Configure Elsa API client.
|
|
services.AddHttpClient<ElsaClient>(httpClient =>
|
|
{
|
|
var url = configuration["Elsa:ServerUrl"]!.TrimEnd('/') + '/';
|
|
var apiKey = configuration["Elsa:ApiKey"]!;
|
|
httpClient.BaseAddress = new Uri(url);
|
|
httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("ApiKey", apiKey);
|
|
});
|
|
|
|
var app = builder.Build();
|
|
|
|
// Configure the HTTP request pipeline.
|
|
if (!app.Environment.IsDevelopment())
|
|
{
|
|
app.UseExceptionHandler("/Home/Error");
|
|
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
|
|
app.UseHsts();
|
|
}
|
|
|
|
app.UseHttpsRedirection();
|
|
app.UseStaticFiles();
|
|
|
|
app.UseRouting();
|
|
|
|
app.UseAuthorization();
|
|
|
|
app.MapControllerRoute(
|
|
name: "default",
|
|
pattern: "{controller=Home}/{action=Index}/{id?}");
|
|
|
|
app.Run(); |