Squirrowse/Squirrowse.Service/Startup.cs

54 lines
1.8 KiB
C#
Raw Normal View History

2019-10-31 13:08:42 +01:00
using System.Reflection;
using MediatR;
2019-10-31 10:23:07 +01:00
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
2019-11-04 14:28:45 +01:00
using Squirrowse.Core;
2019-10-31 12:53:57 +01:00
using Squirrowse.Service.Hubs;
2019-10-31 10:23:07 +01:00
namespace Squirrowse.Service
{
public class Startup
{
public Startup(IConfiguration configuration)
{
Configuration = configuration;
}
public IConfiguration Configuration { get; }
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
services.AddControllers();
2019-10-31 13:08:42 +01:00
services.AddMediatR(Assembly.GetAssembly(typeof(Startup)));
2019-11-08 16:36:20 +01:00
//services.AddSingleton<IStreamHub, StreamHub>();
2019-11-06 19:17:06 +01:00
services.AddSingleton<IStreamManager, StreamManager>();
2019-11-04 14:28:45 +01:00
services.AddCoreModule();
2019-10-31 12:53:57 +01:00
services.AddSignalR()
2019-11-04 09:29:37 +01:00
.AddHubOptions<StreamHub
>(opt => opt.MaximumReceiveMessageSize = 102400000) //~100mb per frame instead of 32kb default
2019-10-31 12:53:57 +01:00
.AddMessagePackProtocol();
2019-10-31 10:23:07 +01:00
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
2019-10-31 12:53:57 +01:00
if (env.IsDevelopment()) app.UseDeveloperExceptionPage();
2019-10-31 10:23:07 +01:00
app.UseHttpsRedirection();
app.UseRouting();
app.UseAuthorization();
app.UseEndpoints(endpoints =>
{
endpoints.MapControllers();
2019-10-31 12:53:57 +01:00
endpoints.MapHub<StreamHub>($"{nameof(StreamHub)}");
2019-10-31 10:23:07 +01:00
});
}
}
2019-10-31 12:53:57 +01:00
}