26 where TApiModel : notnull
28 if (authorityResponse.IsNoContent!.Value)
29 return controller.NoContent();
31 var successResponse = authorityResponse.SuccessResponse;
32 var result = resultTransformer(authorityResponse.Result!);
33 return successResponse
switch
35 HttpSuccessResponse.Ok => controller.Json(result),
36 HttpSuccessResponse.Created => controller.Created(result),
37 HttpSuccessResponse.Accepted => controller.Accepted(result),
38 _ =>
throw new InvalidOperationException($
"Invalid {nameof(HttpSuccessResponse)}: {successResponse}"),
55 return failureResponse
switch
57 HttpFailureResponse.BadRequest => controller.BadRequest(errorMessage),
58 HttpFailureResponse.Unauthorized => controller.Unauthorized(),
59 HttpFailureResponse.Forbidden => controller.Forbid(),
60 HttpFailureResponse.NotFound => controller.
NotFound(errorMessage),
61 HttpFailureResponse.NotAcceptable => controller.
StatusCode(HttpStatusCode.NotAcceptable, errorMessage),
62 HttpFailureResponse.Conflict => controller.Conflict(errorMessage),
63 HttpFailureResponse.Gone => controller.
StatusCode(HttpStatusCode.Gone, errorMessage),
64 HttpFailureResponse.UnprocessableEntity => controller.UnprocessableEntity(errorMessage),
65 HttpFailureResponse.FailedDependency => controller.
StatusCode(HttpStatusCode.FailedDependency, errorMessage),
66 HttpFailureResponse.RateLimited => controller.
StatusCode(HttpStatusCode.TooManyRequests, errorMessage),
67 HttpFailureResponse.NotImplemented => controller.
StatusCode(HttpStatusCode.NotImplemented, errorMessage),
68 HttpFailureResponse.ServiceUnavailable => controller.
StatusCode(HttpStatusCode.ServiceUnavailable, errorMessage),
69 _ =>
throw new InvalidOperationException($
"Invalid {nameof(HttpFailureResponse)}: {failureResponse}"),
85 ArgumentNullException.ThrowIfNull(controller);
86 ArgumentNullException.ThrowIfNull(authorityInvoker);
88 var authorityResponse = await authorityInvoker(
Authority);
95 ArgumentNullException.ThrowIfNull(controller);
96 ArgumentNullException.ThrowIfNull(authorityInvoker);
98 var authorityResponse = await authorityInvoker(
Authority);
100 if (erroredResult !=
null)
101 return erroredResult;
103 return CreateSuccessfulActionResult(controller, result => result, authorityResponse);
109 ArgumentNullException.ThrowIfNull(controller);
110 ArgumentNullException.ThrowIfNull(authorityInvoker);
112 var authorityResponse = await authorityInvoker(
Authority);
114 if (erroredResult !=
null)
115 return erroredResult;
117 return CreateSuccessfulActionResult(controller, result => result.ToApi(), authorityResponse);