mirror of
https://github.com/lidarr/lidarr.git
synced 2025-07-16 10:03:51 -07:00
replaced most of ServiceStack with nancy.
This commit is contained in:
parent
936886f213
commit
acef97b79f
22 changed files with 15057 additions and 334 deletions
31
NzbDrone.Api/QualityType/RequestExtensions.cs
Normal file
31
NzbDrone.Api/QualityType/RequestExtensions.cs
Normal file
|
@ -0,0 +1,31 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using Nancy;
|
||||
using Nancy.Responses;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace NzbDrone.Api.QualityType
|
||||
{
|
||||
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, new JsonSerializerSettings
|
||||
{
|
||||
NullValueHandling = NullValueHandling.Ignore,
|
||||
MissingMemberHandling = MissingMemberHandling.Ignore
|
||||
});
|
||||
}
|
||||
|
||||
public static Response AsResponse<TModel>(this TModel model, HttpStatusCode statusCode = HttpStatusCode.OK)
|
||||
{
|
||||
ISerializer serializer = new DefaultJsonSerializer();
|
||||
var jsonResponse = new JsonResponse<TModel>(model, serializer) {StatusCode = statusCode};
|
||||
return jsonResponse;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue