2023-01-25 13:48:50 +00:00
|
|
|
using BinaryDad.Notes;
|
2023-01-05 15:32:21 +00:00
|
|
|
using BinaryDad.Notes.Services;
|
2023-05-10 20:22:51 +00:00
|
|
|
using Microsoft.AspNetCore.Authentication.Cookies;
|
2023-01-05 15:32:21 +00:00
|
|
|
|
2022-11-29 15:14:15 +00:00
|
|
|
var builder = WebApplication.CreateBuilder(args);
|
|
|
|
|
|
|
|
// Add services to the container.
|
|
|
|
builder.Services.AddControllersWithViews();
|
2023-01-25 13:48:50 +00:00
|
|
|
builder.Services.AddSignalR();
|
2023-01-05 15:32:21 +00:00
|
|
|
builder.Services.AddSingleton<INoteService, FileNoteService>();
|
2022-11-29 15:14:15 +00:00
|
|
|
|
2023-05-10 20:22:51 +00:00
|
|
|
builder.Services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme).AddCookie(o =>
|
|
|
|
{
|
|
|
|
o.LoginPath = "/login";
|
2023-06-21 14:49:13 +00:00
|
|
|
o.Cookie.Name = "NotesUser";
|
|
|
|
o.Cookie.MaxAge = TimeSpan.FromDays(3);
|
2023-05-10 20:22:51 +00:00
|
|
|
});
|
|
|
|
|
2022-11-29 15:14:15 +00:00
|
|
|
var app = builder.Build();
|
|
|
|
|
|
|
|
// Configure the HTTP request pipeline.
|
|
|
|
if (!app.Environment.IsDevelopment())
|
|
|
|
{
|
2023-01-09 21:56:30 +00:00
|
|
|
app.UseHttpsRedirection();
|
2022-11-29 15:14:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
app.UseStaticFiles();
|
|
|
|
|
|
|
|
app.UseRouting();
|
2023-05-10 20:22:51 +00:00
|
|
|
app.UseAuthentication();
|
2022-11-29 15:14:15 +00:00
|
|
|
app.UseAuthorization();
|
|
|
|
|
|
|
|
app.MapControllerRoute(
|
|
|
|
name: "default",
|
2023-05-10 20:22:51 +00:00
|
|
|
pattern: "{controller=Note}/{action=Index}/{id?}");
|
2022-11-29 15:14:15 +00:00
|
|
|
|
2023-01-25 13:48:50 +00:00
|
|
|
app.MapHub<NoteHub>("/noteHub");
|
|
|
|
|
2022-11-29 15:14:15 +00:00
|
|
|
app.Run();
|