BotSharp/src/WebStarter/Program.cs

53 lines
1.1 KiB
C#
Raw Normal View History

2023-07-25 02:22:18 +00:00
using BotSharp.Abstraction.Users;
2023-05-27 01:58:31 +00:00
using BotSharp.Core;
2023-12-19 13:16:43 +00:00
using BotSharp.OpenAPI;
2023-07-25 02:22:18 +00:00
using BotSharp.Core.Users.Services;
2023-11-29 23:23:14 +00:00
using BotSharp.Logger;
2023-11-27 02:04:05 +00:00
using BotSharp.Plugin.ChatHub;
2023-05-27 01:58:31 +00:00
2023-05-26 01:36:15 +00:00
var builder = WebApplication.CreateBuilder(args);
2023-07-25 02:22:18 +00:00
builder.Services.AddScoped<IUserIdentity, UserIdentity>();
2023-05-27 01:58:31 +00:00
// Add BotSharp
2023-11-29 23:23:14 +00:00
builder.Services.AddBotSharpCore(builder.Configuration);
2023-12-19 13:16:43 +00:00
builder.Services.AddBotSharpOpenAPI(builder.Configuration);
2023-11-29 23:23:14 +00:00
builder.Services.AddBotSharpLogger(builder.Configuration);
2023-08-14 18:16:35 +00:00
2023-06-03 02:07:30 +00:00
builder.Services.AddCors(options =>
{
options.AddPolicy("MyCorsPolicy",
2023-11-27 02:04:05 +00:00
builder => builder.WithOrigins("http://localhost:5010")
2023-06-03 02:07:30 +00:00
.AllowAnyMethod()
2023-11-27 02:04:05 +00:00
.AllowAnyHeader()
.AllowCredentials());
2023-06-03 02:07:30 +00:00
});
2023-11-27 02:04:05 +00:00
builder.Services.AddSignalR();
2023-05-26 01:36:15 +00:00
var app = builder.Build();
// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
app.UseSwagger();
app.UseSwaggerUI();
}
2023-11-28 03:19:07 +00:00
app.MapHub<SignalRHub>("/chatHub");
app.UseMiddleware<WebSocketsMiddleware>();
2023-06-11 23:46:02 +00:00
app.UseAuthentication();
2023-05-26 01:36:15 +00:00
app.UseAuthorization();
app.MapControllers();
2023-05-27 01:58:31 +00:00
// Use BotSharp
app.UseBotSharp();
2023-06-03 02:07:30 +00:00
#if DEBUG
app.UseCors("MyCorsPolicy");
#endif
2023-05-26 01:36:15 +00:00
app.Run();