mirror of
https://github.com/yawaflua/Telegram-Bot-Template.git
synced 2025-12-10 20:39:34 +02:00
Add project files.
This commit is contained in:
54
Startup.cs
Normal file
54
Startup.cs
Normal file
@@ -0,0 +1,54 @@
|
||||
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();
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user