mirror of
https://github.com/yawaflua/Telegram-Bot-Template.git
synced 2025-12-09 03:49:30 +02:00
55 lines
1.6 KiB
C#
55 lines
1.6 KiB
C#
using Microsoft.AspNetCore.Hosting.Server;
|
|
using System;
|
|
|
|
namespace TG_Bot_Template
|
|
{
|
|
public class Startup
|
|
{
|
|
public class Startup
|
|
{
|
|
private readonly IConfiguration configuration;
|
|
|
|
public Startup()
|
|
{
|
|
configuration = new ConfigurationBuilder()
|
|
.AddEnvironmentVariables()
|
|
.AddJsonFile("appsettings.json", optional: true)
|
|
.Build();
|
|
}
|
|
|
|
public void ConfigureServices(IServiceCollection services)
|
|
{
|
|
services.AddControllers();
|
|
services
|
|
.AddSwaggerGen();
|
|
|
|
services
|
|
.AddSingleton(configuration)
|
|
.AddSingleton(x => x.CreateScope())
|
|
.AddHostedService<TelegramBotService>();
|
|
|
|
}
|
|
|
|
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
|
|
{
|
|
if (env.IsDevelopment())
|
|
{
|
|
app.UseDeveloperExceptionPage();
|
|
app.UseSwagger();
|
|
app.UseSwagger(c =>
|
|
{
|
|
c.RouteTemplate = "/swagger/v1/swagger.json";
|
|
});
|
|
}
|
|
app.UseStaticFiles();
|
|
app.UseRouting();
|
|
app.UseCors(k => { k.AllowAnyHeader(); k.AllowAnyMethod(); k.AllowAnyOrigin(); k.WithMethods("POST", "GET"); });
|
|
app.UseEndpoints(endpoints =>
|
|
{
|
|
endpoints.MapControllers();
|
|
});
|
|
}
|
|
}
|
|
}
|
|
}
|