mirror of
https://github.com/lidarr/lidarr.git
synced 2025-08-14 18:57:39 -07:00
added commands.
they can be triggered using the api api/command/
This commit is contained in:
parent
68ee71ea81
commit
182192e0ba
31 changed files with 265 additions and 74 deletions
|
@ -1,4 +1,5 @@
|
|||
using System.IO;
|
||||
using System;
|
||||
using System.IO;
|
||||
using Nancy;
|
||||
using Nancy.Responses;
|
||||
using NzbDrone.Common;
|
||||
|
@ -11,11 +12,16 @@ namespace NzbDrone.Api.Extensions
|
|||
private static readonly NancyJsonSerializer NancySerializer = new NancyJsonSerializer(Serializer);
|
||||
|
||||
public static T FromJson<T>(this Stream body) where T : class, new()
|
||||
{
|
||||
return FromJson<T>(body, typeof(T));
|
||||
}
|
||||
|
||||
public static T FromJson<T>(this Stream body, Type type)
|
||||
{
|
||||
var reader = new StreamReader(body, true);
|
||||
body.Position = 0;
|
||||
var value = reader.ReadToEnd();
|
||||
return Serializer.Deserialize<T>(value);
|
||||
return (T)Serializer.Deserialize(value, type);
|
||||
}
|
||||
|
||||
public static JsonResponse<TModel> AsResponse<TModel>(this TModel model, HttpStatusCode statusCode = HttpStatusCode.OK)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue