Skip to content

Commit 563b0af

Browse files
authored
Merge pull request #25 from EisernUnion/master
Added REST API
2 parents bd553d2 + 92ba255 commit 563b0af

File tree

2 files changed

+48
-1
lines changed

2 files changed

+48
-1
lines changed
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
using HueLightDJ.Services; // ✅ KORREKT - Nicht . Internal
2+
using Microsoft.AspNetCore.Mvc;
3+
4+
namespace HueEntertainmentPro.Server.Controllers
5+
{
6+
[Route("api")]
7+
[ApiController]
8+
public class ApiController : ControllerBase
9+
{
10+
private readonly EffectService _effectService;
11+
12+
public ApiController(EffectService effectService)
13+
{
14+
_effectService = effectService;
15+
}
16+
17+
/// <summary>
18+
/// Triggers a beat effect with the specified intensity
19+
/// </summary>
20+
/// <param name="intensity">Beat intensity (typically 0.0 to 1.0)</param>
21+
[HttpPost("beat")]
22+
public IActionResult Beat([FromBody] double intensity)
23+
{
24+
try
25+
{
26+
_effectService.Beat(intensity);
27+
return Ok(new { success = true, message = "Beat triggered successfully" });
28+
}
29+
catch (System.Exception ex)
30+
{
31+
return StatusCode(500, new { success = false, error = ex.Message });
32+
}
33+
}
34+
35+
/// <summary>
36+
/// Test endpoint to verify API is working
37+
/// </summary>
38+
[HttpGet("test")]
39+
public IActionResult Test()
40+
{
41+
return Ok(new { status = "API is working", timestamp = System.DateTime.UtcNow });
42+
}
43+
}
44+
}

HueEntertainmentPro/Server/Program.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
builder.Services.AddFluentUIComponents();
2727
builder.Services.AddSignalR();
2828

29+
builder.Services.AddControllers();
30+
2931
builder.Services.AddGrpc();
3032
builder.Services.AddResponseCompression(opts =>
3133
{
@@ -70,11 +72,12 @@
7072
app.UseHsts();
7173
}
7274

73-
//app.UseHttpsRedirection();
75+
app.UseHttpsRedirection();
7476

7577
app.UseBlazorFrameworkFiles();
7678
app.UseStaticFiles();
7779

80+
7881
//Reverse Proxy to Hue Bridge, disabled in DEMO mode
7982
if (app.Environment.EnvironmentName != "DEMO")
8083
{

0 commit comments

Comments
 (0)