aboutsummaryrefslogtreecommitdiffstats
path: root/code/api/Endpoints/EndpointBase.cs
blob: a16f40f0fe175d4744d4fff3f5c05cb6755970d2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
namespace I2R.Storage.Api.Endpoints;

[ApiController]
[Authorize]
public class EndpointBase : ControllerBase
{
    protected LoggedInUserModel LoggedInUser => new(User);

    [NonAction]
    protected ActionResult KnownProblem(string title = default, string subtitle = default, Dictionary<string, string[]> errors = default) {
        return BadRequest(new KnownProblemModel {
            Title = title,
            Subtitle = subtitle,
            Errors = errors,
            TraceId = HttpContext.TraceIdentifier
        });
    }

    [NonAction]
    protected ActionResult KnownProblem(KnownProblemModel problem) {
        problem.TraceId = HttpContext.TraceIdentifier;
        return BadRequest(problem);
    }
}