Squash and merge of version-0.1 Co-authored-by: James Wampler <james@wamp.dev> Co-committed-by: James Wampler <james@wamp.dev>
20 lines
741 B
C#
Executable File
20 lines
741 B
C#
Executable File
using MicCheck.Api.Common.Security.Authorization;
|
|
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
namespace MicCheck.Api.Features;
|
|
|
|
[ApiController]
|
|
[Route("api/v1/flags")]
|
|
[Authorize(Policy = AuthorizationPolicies.FlagsApiAccess)]
|
|
public class FlagsController(FeatureEvaluationService featureEvaluationService) : ControllerBase
|
|
{
|
|
[HttpGet]
|
|
public async Task<ActionResult<IReadOnlyList<FlagResponse>>> GetAll(CancellationToken ct)
|
|
{
|
|
var environmentId = int.Parse(User.FindFirst("EnvironmentId")!.Value);
|
|
var results = await featureEvaluationService.EvaluateForEnvironmentAsync(environmentId, ct);
|
|
return Ok(results.Select(FlagResponse.From).ToList());
|
|
}
|
|
}
|