Created
September 3, 2021 21:08
-
-
Save crgrieve/bcb3b995214dbf731fc5b22829fb994f to your computer and use it in GitHub Desktop.
C#10 API program.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Microsoft.OpenApi.Models; | |
var builder = WebApplication.CreateBuilder(args); | |
// Add services to the container. | |
builder.Services.AddControllers(); | |
builder.Services.AddSwaggerGen(c => | |
{ | |
c.SwaggerDoc("v1", new() { Title = "dotnet6PreviewAPI", Version = "v1" }); | |
}); | |
var app = builder.Build(); | |
// Configure the HTTP request pipeline. | |
if (builder.Environment.IsDevelopment()) | |
{ | |
app.UseDeveloperExceptionPage(); | |
app.UseSwagger(); | |
app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "dotnet6PreviewAPI v1")); | |
} | |
app.UseHttpsRedirection(); | |
app.UseAuthorization(); | |
app.MapControllers(); | |
app.Run(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment