mirror of
https://github.com/eliasstepanik/SimpleFunctions.git
synced 2026-01-10 21:28:29 +00:00
74 lines
2.2 KiB
C#
74 lines
2.2 KiB
C#
using Docker.DotNet;
|
|
using Docker.DotNet.Models;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
namespace TestFunction.Controllers;
|
|
|
|
[ApiController]
|
|
[Route("")]
|
|
public class TestController : ControllerBase
|
|
{
|
|
private static readonly string[] Summaries = new[]
|
|
{
|
|
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
|
|
};
|
|
|
|
private readonly ILogger<TestController> _logger;
|
|
|
|
public TestController(ILogger<TestController> logger)
|
|
{
|
|
_logger = logger;
|
|
}
|
|
|
|
[HttpGet]
|
|
public IEnumerable<WeatherForecast> Get()
|
|
{
|
|
return Enumerable.Range(1, 5).Select(index => new WeatherForecast
|
|
{
|
|
Date = DateOnly.FromDateTime(DateTime.Now.AddDays(index)),
|
|
TemperatureC = Random.Shared.Next(-20, 55),
|
|
Summary = Summaries[Random.Shared.Next(Summaries.Length)]
|
|
})
|
|
.ToArray();
|
|
}
|
|
|
|
[HttpPost]
|
|
public async Task<ContainerStatsResponse> Post(string id)
|
|
{
|
|
return await Test.GetLoad(id);
|
|
}
|
|
|
|
[HttpPatch]
|
|
public IEnumerable<WeatherForecast> Patch()
|
|
{
|
|
return Enumerable.Range(1, 5).Select(index => new WeatherForecast
|
|
{
|
|
Date = DateOnly.FromDateTime(DateTime.Now.AddDays(index)),
|
|
TemperatureC = Random.Shared.Next(-20, 55),
|
|
Summary = Summaries[Random.Shared.Next(Summaries.Length)]
|
|
})
|
|
.ToArray();
|
|
}
|
|
[HttpDelete]
|
|
public IEnumerable<WeatherForecast> Delete()
|
|
{
|
|
return Enumerable.Range(1, 5).Select(index => new WeatherForecast
|
|
{
|
|
Date = DateOnly.FromDateTime(DateTime.Now.AddDays(index)),
|
|
TemperatureC = Random.Shared.Next(-20, 55),
|
|
Summary = Summaries[Random.Shared.Next(Summaries.Length)]
|
|
})
|
|
.ToArray();
|
|
}
|
|
[HttpPut]
|
|
public IEnumerable<WeatherForecast> Put()
|
|
{
|
|
return Enumerable.Range(1, 5).Select(index => new WeatherForecast
|
|
{
|
|
Date = DateOnly.FromDateTime(DateTime.Now.AddDays(index)),
|
|
TemperatureC = Random.Shared.Next(-20, 55),
|
|
Summary = Summaries[Random.Shared.Next(Summaries.Length)]
|
|
})
|
|
.ToArray();
|
|
}
|
|
} |