Skip to content

Commit

Permalink
Move from controller to minimal API
Browse files Browse the repository at this point in the history
  • Loading branch information
djvelimir committed Dec 19, 2024
1 parent 0ad9cd7 commit f15aa02
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 33 deletions.
24 changes: 0 additions & 24 deletions DemoDotnetWebApi/Controllers/PasswordController.cs

This file was deleted.

20 changes: 11 additions & 9 deletions DemoDotnetWebApi/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,26 @@
builder.Services.AddTransient<IRandomCharacterGenerator, RandomCharacterGenerator>();
builder.Services.AddTransient<IStringShuffler, StringShuffler>();

builder.Services.AddControllers();
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
builder.Services.AddOpenApi();

var app = builder.Build();

// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
app.UseSwagger();
app.UseSwaggerUI();
app.MapOpenApi();
app.UseSwaggerUI(options =>
{
options.SwaggerEndpoint("/openapi/v1.json", "Demo API");
});
}

app.UseHttpsRedirection();

app.UseAuthorization();

app.MapControllers();
app.MapGet("/api/v1/password", (IPasswordGenerator _passwordGenerator) =>
{
return _passwordGenerator.Generate();
})
.WithName("GetPassword");

app.Run();

0 comments on commit f15aa02

Please sign in to comment.