Created
October 6, 2025 09:37
-
-
Save uzbekdev1/8a0699f4f65f303f7961a6d03e26ea7f to your computer and use it in GitHub Desktop.
Revisions
-
uzbekdev1 revised this gist
Oct 6, 2025 . 1 changed file with 17 additions and 38 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,46 +1,25 @@ public class GlobalMiddleware { private readonly RequestDelegate _next; private string _requestBody; public GlobalMiddleware(RequestDelegate next) { _next = next; } public async Task Invoke(HttpContext context) { if (context.Request.Method == "PUT" || context.Request.Method == "POST"|| context.Request.Method == "PATCH") { context.Request.EnableBuffering(); _requestBody = await new StreamReader(context.Request.Body).ReadToEndAsync(); context.Request.Body.Position = 0; } await _next(context); } } -
uzbekdev1 created this gist
Oct 6, 2025 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,46 @@ using AppEnvironment; using BusinessLogic.Core; using ClientApi.Consts; using ClientApi.Core; using ClientApi.Helpers; using DataAccess.Helpers; using DataAccess.Services; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http.Extensions; using Microsoft.Extensions.Logging; using System; using System.IO; using System.Linq; using System.Net.Http; using System.Security.Claims; using System.Text; using System.Threading.Tasks; namespace ClientApi.Middlewares { public class GlobalMiddleware { private readonly RequestDelegate _next; private string _requestBody; public GlobalMiddleware(RequestDelegate next) { _next = next; } public async Task Invoke(HttpContext context) { if (context.Request.Method == "PUT" || context.Request.Method == "POST"|| context.Request.Method == "PATCH") { context.Request.EnableBuffering(); _requestBody = await new StreamReader(context.Request.Body).ReadToEndAsync(); context.Request.Body.Position = 0; } await _next(context); } } }