-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProgram.cs
33 lines (25 loc) · 874 Bytes
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
using DemoDotnetWebApi.Interfaces;
using DemoDotnetWebApi.Services;
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
builder.Services.AddTransient<IPasswordGenerator, PasswordGenerator>();
builder.Services.AddTransient<IRandomCharacterGenerator, RandomCharacterGenerator>();
builder.Services.AddTransient<IStringShuffler, StringShuffler>();
builder.Services.AddOpenApi();
var app = builder.Build();
// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
app.MapOpenApi();
app.UseSwaggerUI(options =>
{
options.SwaggerEndpoint("/openapi/v1.json", "Demo API");
});
}
app.UseHttpsRedirection();
app.MapGet("/api/v1/password", (IPasswordGenerator _passwordGenerator) =>
{
return _passwordGenerator.Generate();
})
.WithName("GetPassword");
app.Run();