29 lines
713 B
C#
29 lines
713 B
C#
using Newtonsoft.Json;
|
|
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace LiveForum.Code.Utility;
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public static class HttpRequestMessageExtensions
|
|
{
|
|
public static async Task<string> ToJsonAsync(this HttpRequestMessage request)
|
|
{
|
|
var requestInfo = new
|
|
{
|
|
Method = request.Method.Method,
|
|
Url = request.RequestUri?.ToString(),
|
|
Headers = request.Headers,
|
|
Content = request.Content != null ? await request.Content.ReadAsStringAsync() : null
|
|
};
|
|
|
|
return JsonConvert.SerializeObject(requestInfo, Formatting.None);
|
|
}
|
|
}
|