mirror of
https://github.com/lidarr/lidarr.git
synced 2025-07-16 10:03:51 -07:00
spelling
This commit is contained in:
parent
c35682376e
commit
cf8be4bf8f
16 changed files with 20 additions and 21 deletions
25
NzbDrone.Api/Extensions/RequestExtensions.cs
Normal file
25
NzbDrone.Api/Extensions/RequestExtensions.cs
Normal file
|
@ -0,0 +1,25 @@
|
|||
using System.IO;
|
||||
using System.Linq;
|
||||
using Nancy;
|
||||
using Nancy.Responses;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace NzbDrone.Api.Extensions
|
||||
{
|
||||
public static class JsonExtensions
|
||||
{
|
||||
public static T FromJson<T>(this Stream body)
|
||||
{
|
||||
var reader = new StreamReader(body, true);
|
||||
body.Position = 0;
|
||||
var value = reader.ReadToEnd();
|
||||
return JsonConvert.DeserializeObject<T>(value, Serializer.Settings);
|
||||
}
|
||||
|
||||
public static JsonResponse<TModel> AsResponse<TModel>(this TModel model, HttpStatusCode statusCode = HttpStatusCode.OK)
|
||||
{
|
||||
var jsonResponse = new JsonResponse<TModel>(model, new NancyJsonSerializer()) { StatusCode = statusCode };
|
||||
return jsonResponse;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue