74 lines
2.3 KiB
C#
74 lines
2.3 KiB
C#
using API_SequentMicrosystems.Hubs;
|
|
using API_SequentMicrosystems.Services;
|
|
using Microsoft.OpenApi.Models;
|
|
using System.Reflection;
|
|
|
|
namespace API_SequentMicrosystems
|
|
{
|
|
public class Program
|
|
{
|
|
public static void Main(string[] args)
|
|
{
|
|
var builder = WebApplication.CreateBuilder(args);
|
|
|
|
// Add services to the container.
|
|
|
|
builder.Services.AddControllers().AddNewtonsoftJson();
|
|
builder.Services.AddSignalR();
|
|
builder.Services.AddSignalRCore();
|
|
|
|
builder.Services.AddSingleton<RTDDAService>();
|
|
builder.Services.AddSingleton<PointsService>();
|
|
|
|
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
|
|
builder.Services.AddEndpointsApiExplorer();
|
|
builder.Services.AddSwaggerGen(c =>
|
|
{
|
|
var xmlFile = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml";
|
|
var xmlPath = Path.Combine(AppContext.BaseDirectory, xmlFile);
|
|
c.IncludeXmlComments(xmlPath);
|
|
|
|
c.SwaggerDoc("v1", new OpenApiInfo
|
|
{
|
|
Version = "v1",
|
|
Title = "SM_API",
|
|
Description = "API of Measure and Control Device",
|
|
Contact = new OpenApiContact
|
|
{
|
|
Name = "Jan Beníèek",
|
|
Email = "jan00@benicek.xyz"
|
|
},
|
|
});
|
|
});
|
|
|
|
var app = builder.Build();
|
|
|
|
// Configure the HTTP request pipeline.
|
|
if (true)//app.Environment.IsDevelopment())
|
|
{
|
|
app.UseSwagger(c =>
|
|
{
|
|
c.RouteTemplate = "api/{documentName}/swagger.json";
|
|
});
|
|
app.UseSwaggerUI(c =>
|
|
{
|
|
c.SwaggerEndpoint("/api/v1/swagger.json", "V1");
|
|
c.RoutePrefix = "api";
|
|
});
|
|
}
|
|
|
|
app.UseAuthorization();
|
|
|
|
app.Services.GetService<RTDDAService>();
|
|
app.Services.GetService<PointsService>();
|
|
|
|
app.MapHub<SyncHub>("/signalr");
|
|
app.UseWebSockets();
|
|
|
|
app.MapControllers();
|
|
|
|
app.Run();
|
|
}
|
|
}
|
|
}
|