mirror of
https://github.com/Radarr/Radarr.git
synced 2026-04-17 21:26:22 -04:00
Updated Nancy to 2.0
This commit is contained in:
@@ -1,22 +1,23 @@
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using Nancy;
|
||||
using Nancy.Responses.Negotiation;
|
||||
using NzbDrone.Common.Serializer;
|
||||
|
||||
namespace Radarr.Http.Extensions
|
||||
{
|
||||
public class NancyJsonSerializer : ISerializer
|
||||
{
|
||||
public bool CanSerialize(string contentType)
|
||||
public bool CanSerialize(MediaRange contentType)
|
||||
{
|
||||
return true;
|
||||
return contentType == "application/json";
|
||||
}
|
||||
|
||||
public void Serialize<TModel>(string contentType, TModel model, Stream outputStream)
|
||||
public void Serialize<TModel>(MediaRange contentType, TModel model, Stream outputStream)
|
||||
{
|
||||
Json.Serialize(model, outputStream);
|
||||
}
|
||||
|
||||
public IEnumerable<string> Extensions { get; private set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,9 +32,9 @@ namespace Radarr.Http.Extensions
|
||||
return Json.Deserialize(value, type);
|
||||
}
|
||||
|
||||
public static JsonResponse<TModel> AsResponse<TModel>(this TModel model, HttpStatusCode statusCode = HttpStatusCode.OK)
|
||||
public static JsonResponse<TModel> AsResponse<TModel>(this TModel model, NancyContext context, HttpStatusCode statusCode = HttpStatusCode.OK)
|
||||
{
|
||||
var response = new JsonResponse<TModel>(model, NancySerializer) { StatusCode = statusCode };
|
||||
var response = new JsonResponse<TModel>(model, NancySerializer, context.Environment) { StatusCode = statusCode };
|
||||
response.Headers.DisableCache();
|
||||
|
||||
return response;
|
||||
@@ -59,4 +59,4 @@ namespace Radarr.Http.Extensions
|
||||
return headers;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user