aboutsummaryrefslogtreecommitdiffstats
path: root/code/api/src/Endpoints/EndpointBase.cs
diff options
context:
space:
mode:
authorivarlovlie <git@ivarlovlie.no>2022-10-24 06:29:23 +0200
committerivarlovlie <git@ivarlovlie.no>2022-10-24 06:29:23 +0200
commit585c5c8537eb21dfc9f16108548e63d9ced3d971 (patch)
tree1582bc45dcab585ec7204f1570019b2ca8de36c5 /code/api/src/Endpoints/EndpointBase.cs
parent4b42c5235482fe0d3811b4e2936614c79e20d970 (diff)
downloadgreatoffice-585c5c8537eb21dfc9f16108548e63d9ced3d971.tar.xz
greatoffice-585c5c8537eb21dfc9f16108548e63d9ced3d971.zip
feat: Before move to FastEndpoints
Diffstat (limited to 'code/api/src/Endpoints/EndpointBase.cs')
-rw-r--r--code/api/src/Endpoints/EndpointBase.cs27
1 files changed, 27 insertions, 0 deletions
diff --git a/code/api/src/Endpoints/EndpointBase.cs b/code/api/src/Endpoints/EndpointBase.cs
new file mode 100644
index 0000000..c088976
--- /dev/null
+++ b/code/api/src/Endpoints/EndpointBase.cs
@@ -0,0 +1,27 @@
+using System.Diagnostics;
+
+namespace IOL.GreatOffice.Api.Endpoints;
+
+[ApiController]
+public class EndpointBase : ControllerBase
+{
+ /// <summary>
+ /// User data for the currently logged on user.
+ /// </summary>
+ protected LoggedInUserModel LoggedInUser => new() {
+ Username = User.FindFirstValue(AppClaims.NAME),
+ Id = User.FindFirstValue(AppClaims.USER_ID).AsGuid(),
+ };
+
+ public ObjectResult KnownProblem(string title = default, string subtitle = default, Dictionary<string, string> errors = default) {
+ return new ObjectResult(new KnownProblemModel {
+ Title = title,
+ Subtitle = subtitle,
+ Errors = errors,
+ TraceId = Activity.Current?.Id,
+ RequestId = HttpContext.TraceIdentifier
+ }) {
+ StatusCode = (int) HttpStatusCode.BadRequest
+ };
+ }
+} \ No newline at end of file