mirror of
https://github.com/Readarr/Readarr.git
synced 2026-04-25 22:36:59 -04:00
added commands.
they can be triggered using the api api/command/
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user