Skip to content

Instantly share code, notes, and snippets.

@dj-nitehawk
Last active October 23, 2023 13:09
Show Gist options
  • Save dj-nitehawk/5d5d325e23c4be43aeccbcb0066a72b4 to your computer and use it in GitHub Desktop.
Save dj-nitehawk/5d5d325e23c4be43aeccbcb0066a72b4 to your computer and use it in GitHub Desktop.
Using old style app host-builder with `Startup.cs`
public class Program
{
public static void Main(string[] args)
=> CreateHostBuilder(args).Build().Run();
public static IHostBuilder CreateHostBuilder(string[] args)
=> Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder => webBuilder.UseStartup<Startup>());
}
public class Startup
{
public IConfiguration Configuration { get; }
public Startup(IConfiguration configuration) { Configuration = configuration; }
public void ConfigureServices(IServiceCollection services)
{
services.AddFastEndpoints()
.SwaggerDocument();
}
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
app.UseRouting()
.UseEndpoints(x => x.MapFastEndpoints())
.UseSwaggerGen();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment