-
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d8a7fdf
commit d31ebbe
Showing
3 changed files
with
35 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
src/Infrastructure.Web.Api.Common/Endpoints/EndpointFilterExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
using Infrastructure.Web.Api.Interfaces; | ||
using Microsoft.AspNetCore.Http; | ||
|
||
namespace Infrastructure.Web.Api.Common.Endpoints; | ||
|
||
public static class EndpointFilterExtensions | ||
{ | ||
/// <summary> | ||
/// Determines the request DTO of the current HTTP request. | ||
/// We expect that all <see cref="RequestDelegate" /> are of this form: (IMediatr mediatr, IWebRequest request) | ||
/// where the second parameter is an instance of a <see cref="IWebRequest{TResponse}" /> | ||
/// </summary> | ||
public static IWebRequest? GetRequestDto(this EndpointFilterInvocationContext context) | ||
{ | ||
var arguments = context.Arguments; | ||
if (arguments.Count < 2) | ||
{ | ||
return null; | ||
} | ||
|
||
var request = context.Arguments[1]!; | ||
if (request is not IWebRequest webRequest) | ||
{ | ||
return null; | ||
} | ||
|
||
return webRequest; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters