Skip to content

Instantly share code, notes, and snippets.

@theburningmonk
Created September 1, 2011 15:16
Show Gist options
  • Save theburningmonk/1186391 to your computer and use it in GitHub Desktop.
Save theburningmonk/1186391 to your computer and use it in GitHub Desktop.
A simple wrapper of Nancy.Response that takes in an object to use as the response body
public class ProtoBufResponse : Response
{
public ProtoBufResponse(object body)
{
ContentType = "application/x-protobuf";
Contents = stream => ProtoBuf.Serializer.Serialize(stream, body);
}
public ProtoBufResponse WithStatusCode(HttpStatusCode httpStatusCode)
{
StatusCode = httpStatusCode;
return this;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment