Skip to content

Commit adeefe8

Browse files
authored
Merge pull request #5 from NiceOneFox/T5_Setup_Controller_Routing
Close T5_Setup_Controller_Routing
2 parents 07fb819 + 881e10c commit adeefe8

File tree

3 files changed

+22
-27
lines changed

3 files changed

+22
-27
lines changed

backend/ServiceSimulation/WebApplication2/Api.csproj

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<Project Sdk="Microsoft.NET.Sdk.Web">
1+
<Project Sdk="Microsoft.NET.Sdk.Web">
22

33
<PropertyGroup>
44
<TargetFramework>net6.0</TargetFramework>
@@ -10,4 +10,8 @@
1010
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.3.0" />
1111
</ItemGroup>
1212

13+
<ItemGroup>
14+
<Folder Include="Controllers\" />
15+
</ItemGroup>
16+
1317
</Project>
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
using Microsoft.AspNetCore.Mvc;
2+
3+
namespace Api.Controllers;
4+
5+
[Route("simulation")]
6+
public class Simulation : Controller
7+
{
8+
[HttpGet("/start")]
9+
public IActionResult Start()
10+
{
11+
return Ok("Simulation answer");
12+
}
13+
}
Lines changed: 4 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
var builder = WebApplication.CreateBuilder(args);
22

3-
// Add services to the container.
4-
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
3+
builder.Services.AddControllers();
54
builder.Services.AddEndpointsApiExplorer();
65
builder.Services.AddSwaggerGen();
76

87
var app = builder.Build();
98

10-
// Configure the HTTP request pipeline.
119
if (app.Environment.IsDevelopment())
1210
{
1311
app.UseSwagger();
@@ -16,28 +14,8 @@
1614

1715
app.UseHttpsRedirection();
1816

19-
var summaries = new[]
20-
{
21-
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
22-
};
23-
24-
app.MapGet("/weatherforecast", () =>
25-
{
26-
var forecast = Enumerable.Range(1, 5).Select(index =>
27-
new WeatherForecast
28-
(
29-
DateTime.Now.AddDays(index),
30-
Random.Shared.Next(-20, 55),
31-
summaries[Random.Shared.Next(summaries.Length)]
32-
))
33-
.ToArray();
34-
return forecast;
35-
})
36-
.WithName("GetWeatherForecast");
17+
app.UseAuthorization();
3718

38-
app.Run();
19+
app.MapControllers();
3920

40-
internal record WeatherForecast(DateTime Date, int TemperatureC, string? Summary)
41-
{
42-
public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
43-
}
21+
app.Run();

0 commit comments

Comments
 (0)