From c86632e979f214722943278c29da26adb2659304 Mon Sep 17 00:00:00 2001 From: daniel-c-harvey Date: Sat, 30 Aug 2025 21:34:09 -0400 Subject: [PATCH] Initial DeepDrftContent CDN API --- .../Controllers/WeatherForecastController.cs | 32 +++++++++++++++++++ DeepDrftContent/DeepDrftContent.csproj | 13 ++++++++ DeepDrftContent/DeepDrftContent.http | 6 ++++ DeepDrftContent/Program.cs | 21 ++++++++++++ DeepDrftContent/WeatherForecast.cs | 12 +++++++ DeepDrftContent/appsettings.Development.json | 8 +++++ DeepDrftContent/appsettings.json | 9 ++++++ 7 files changed, 101 insertions(+) create mode 100644 DeepDrftContent/Controllers/WeatherForecastController.cs create mode 100644 DeepDrftContent/DeepDrftContent.csproj create mode 100644 DeepDrftContent/DeepDrftContent.http create mode 100644 DeepDrftContent/Program.cs create mode 100644 DeepDrftContent/WeatherForecast.cs create mode 100644 DeepDrftContent/appsettings.Development.json create mode 100644 DeepDrftContent/appsettings.json diff --git a/DeepDrftContent/Controllers/WeatherForecastController.cs b/DeepDrftContent/Controllers/WeatherForecastController.cs new file mode 100644 index 0000000..27dfb37 --- /dev/null +++ b/DeepDrftContent/Controllers/WeatherForecastController.cs @@ -0,0 +1,32 @@ +using Microsoft.AspNetCore.Mvc; + +namespace DeepDrftContent.Controllers; + +[ApiController] +[Route("[controller]")] +public class WeatherForecastController : ControllerBase +{ + private static readonly string[] Summaries = new[] + { + "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching" + }; + + private readonly ILogger _logger; + + public WeatherForecastController(ILogger logger) + { + _logger = logger; + } + + [HttpGet(Name = "GetWeatherForecast")] + public IEnumerable 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(); + } +} \ No newline at end of file diff --git a/DeepDrftContent/DeepDrftContent.csproj b/DeepDrftContent/DeepDrftContent.csproj new file mode 100644 index 0000000..d46735b --- /dev/null +++ b/DeepDrftContent/DeepDrftContent.csproj @@ -0,0 +1,13 @@ + + + + net9.0 + enable + enable + + + + + + + diff --git a/DeepDrftContent/DeepDrftContent.http b/DeepDrftContent/DeepDrftContent.http new file mode 100644 index 0000000..06fd860 --- /dev/null +++ b/DeepDrftContent/DeepDrftContent.http @@ -0,0 +1,6 @@ +@DeepDrftContent_HostAddress = http://localhost:5070 + +GET {{DeepDrftContent_HostAddress}}/weatherforecast/ +Accept: application/json + +### diff --git a/DeepDrftContent/Program.cs b/DeepDrftContent/Program.cs new file mode 100644 index 0000000..2f04047 --- /dev/null +++ b/DeepDrftContent/Program.cs @@ -0,0 +1,21 @@ +var builder = WebApplication.CreateBuilder(args); + +// Add services to the container. + +builder.Services.AddControllers(); +// Learn more about configuring OpenAPI at https://aka.ms/aspnet/openapi +builder.Services.AddOpenApi(); + +var app = builder.Build(); + +// Configure the HTTP request pipeline. +if (app.Environment.IsDevelopment()) +{ + app.MapOpenApi(); +} + +app.UseAuthorization(); + +app.MapControllers(); + +app.Run(); \ No newline at end of file diff --git a/DeepDrftContent/WeatherForecast.cs b/DeepDrftContent/WeatherForecast.cs new file mode 100644 index 0000000..dd51861 --- /dev/null +++ b/DeepDrftContent/WeatherForecast.cs @@ -0,0 +1,12 @@ +namespace DeepDrftContent; + +public class WeatherForecast +{ + public DateOnly Date { get; set; } + + public int TemperatureC { get; set; } + + public int TemperatureF => 32 + (int)(TemperatureC / 0.5556); + + public string? Summary { get; set; } +} \ No newline at end of file diff --git a/DeepDrftContent/appsettings.Development.json b/DeepDrftContent/appsettings.Development.json new file mode 100644 index 0000000..0c208ae --- /dev/null +++ b/DeepDrftContent/appsettings.Development.json @@ -0,0 +1,8 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + } +} diff --git a/DeepDrftContent/appsettings.json b/DeepDrftContent/appsettings.json new file mode 100644 index 0000000..10f68b8 --- /dev/null +++ b/DeepDrftContent/appsettings.json @@ -0,0 +1,9 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + }, + "AllowedHosts": "*" +}