How can I use the content negotiation pipeline when assigning NancyContext.Response?
Currently, my method IStatusCodeHandler.Handlereturns JSON regardless of any content negotiation.
I want this method to use JSON or XML in accordance with any content negotiation (preferably using a content negotiation pipeline).
public void Handle(HttpStatusCode statusCode, NancyContext context)
{
var error = new { StatusCode = statusCode, Message = "Not Found" };
context.Response =
new JsonResponse(error, new JsonNetSerializer())
.WithStatusCode(statusCode);
}
source
share