From 65c398a5789b567c0e155cafe5de2b715c127818 Mon Sep 17 00:00:00 2001 From: Fritiof Hedman Date: Sun, 7 Jun 2026 13:48:02 +0200 Subject: [PATCH] 0.2 Minimal Program.cs Wire up MVC controllers and add GET /health returning { status: "Healthy", mqttConnected: false } (mqttConnected hardcoded until the MQTT publisher lands). Switch launchSettings.json to port 8080 so the DoD curl works out of the box. Co-Authored-By: Claude Opus 4.7 (1M context) --- IMPLEMENTATION.md | 2 +- src/FrameProcessor/Controllers/HealthController.cs | 11 +++++++++++ src/FrameProcessor/Program.cs | 5 ++++- src/FrameProcessor/Properties/launchSettings.json | 4 ++-- 4 files changed, 18 insertions(+), 4 deletions(-) create mode 100644 src/FrameProcessor/Controllers/HealthController.cs diff --git a/IMPLEMENTATION.md b/IMPLEMENTATION.md index 3032b94..8d13f0f 100644 --- a/IMPLEMENTATION.md +++ b/IMPLEMENTATION.md @@ -15,7 +15,7 @@ When working through this file, mark increments complete by changing `[ ]` to `[ - Add `.gitignore` (dotnet template), `global.json` pinning .NET 10 SDK. - **DoD:** `dotnet build` and `dotnet test` both succeed (no tests yet, but harness runs). -### [ ] 0.2 Minimal Program.cs +### [x] 0.2 Minimal Program.cs - Minimal hosting + controllers wired up. - `GET /health` returning `{ status: "Healthy", mqttConnected: false }` (mqttConnected hardcoded for now). - **DoD:** `dotnet run --project src/FrameProcessor` then `curl localhost:8080/health` returns 200 with the JSON. diff --git a/src/FrameProcessor/Controllers/HealthController.cs b/src/FrameProcessor/Controllers/HealthController.cs new file mode 100644 index 0000000..6a66177 --- /dev/null +++ b/src/FrameProcessor/Controllers/HealthController.cs @@ -0,0 +1,11 @@ +using Microsoft.AspNetCore.Mvc; + +namespace FrameProcessor.Controllers; + +[ApiController] +[Route("health")] +public class HealthController : ControllerBase +{ + [HttpGet] + public IActionResult Get() => Ok(new { status = "Healthy", mqttConnected = false }); +} diff --git a/src/FrameProcessor/Program.cs b/src/FrameProcessor/Program.cs index 1760df1..dc7c950 100644 --- a/src/FrameProcessor/Program.cs +++ b/src/FrameProcessor/Program.cs @@ -1,6 +1,9 @@ var builder = WebApplication.CreateBuilder(args); + +builder.Services.AddControllers(); + var app = builder.Build(); -app.MapGet("/", () => "Hello World!"); +app.MapControllers(); app.Run(); diff --git a/src/FrameProcessor/Properties/launchSettings.json b/src/FrameProcessor/Properties/launchSettings.json index 8a582bf..eb952a5 100644 --- a/src/FrameProcessor/Properties/launchSettings.json +++ b/src/FrameProcessor/Properties/launchSettings.json @@ -5,7 +5,7 @@ "commandName": "Project", "dotnetRunMessages": true, "launchBrowser": true, - "applicationUrl": "http://localhost:5165", + "applicationUrl": "http://localhost:8080", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" } @@ -14,7 +14,7 @@ "commandName": "Project", "dotnetRunMessages": true, "launchBrowser": true, - "applicationUrl": "https://localhost:7016;http://localhost:5165", + "applicationUrl": "https://localhost:7016;http://localhost:8080", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" }