Skip to content

Commit 47cfdb5

Browse files
committed
Add optional param to add user middleware after routing
1 parent efc1ab7 commit 47cfdb5

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/JsonApiDotNetCore/Extensions/IApplicationBuilderExtensions.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,9 @@ public static class IApplicationBuilderExtensions
1818
/// Adds necessary components such as routing to your application
1919
/// </summary>
2020
/// <param name="app"></param>
21+
/// <param name="AddUserMiddleware"></param>
2122
/// <returns></returns>
22-
public static void UseJsonApi(this IApplicationBuilder app)
23+
public static void UseJsonApi(this IApplicationBuilder app, Action<IApplicationBuilder> AddUserMiddleware = null)
2324
{
2425
LogResourceGraphValidations(app);
2526
using (var scope = app.ApplicationServices.CreateScope())
@@ -31,6 +32,10 @@ public static void UseJsonApi(this IApplicationBuilder app)
3132
// An endpoint is selected and set on the HttpContext if a match is found
3233
app.UseRouting();
3334

35+
// user defined middleware to run after routing occurs.
36+
if (AddUserMiddleware != null)
37+
AddUserMiddleware(app);
38+
3439
// middleware to run after routing occurs.
3540
app.UseMiddleware<CurrentRequestMiddleware>();
3641

0 commit comments

Comments
 (0)