mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-09-16 15:22:27 +02:00
22 lines
620 B
C#
22 lines
620 B
C#
using System.Diagnostics.CodeAnalysis;
|
|
using System.IO;
|
|
using System.Net;
|
|
using Newtonsoft.Json;
|
|
using Robust.Shared.Utility;
|
|
|
|
namespace Robust.Server.ServerStatus
|
|
{
|
|
public static class StatusHostHelpers
|
|
{
|
|
[return: MaybeNull]
|
|
public static T GetFromJson<T>(this HttpListenerRequest request)
|
|
{
|
|
using var streamReader = new StreamReader(request.InputStream, EncodingHelpers.UTF8);
|
|
using var jsonReader = new JsonTextReader(streamReader);
|
|
|
|
var serializer = new JsonSerializer();
|
|
return serializer.Deserialize<T>(jsonReader);
|
|
}
|
|
}
|
|
}
|