aboutsummaryrefslogtreecommitdiffstats
path: root/code/api/Endpoints/EndpointBase.cs
blob: b2773e148c23da2675d69bbcb8a437cc24011912 (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
25
26
namespace Quality.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) {
		HttpContext.Response.Headers.Append(AppHeaders.IS_KNOWN_PROBLEM, "1");
		return BadRequest(new KnownProblemModel {
				Title = title,
				Subtitle = subtitle,
				Errors = errors,
				TraceId = HttpContext.TraceIdentifier
		});
	}

	[NonAction]
	protected ActionResult KnownProblem(KnownProblemModel problem) {
		HttpContext.Response.Headers.Append(AppHeaders.IS_KNOWN_PROBLEM, "1");
		problem.TraceId = HttpContext.TraceIdentifier;
		return BadRequest(problem);
	}
}