Skip to content

Instantly share code, notes, and snippets.

@theburningmonk
Created September 1, 2011 14:55
Show Gist options
  • Save theburningmonk/1186335 to your computer and use it in GitHub Desktop.
Save theburningmonk/1186335 to your computer and use it in GitHub Desktop.
An simple Nancy module which uses protobuf-net to serialize the response body
public class MainModule : NancyModule
{
public MainModule()
{
Post["/bindProtobuf"] =
x =>
{
User data = this.Bind();
return new Response
{
ContentType = "application/x-protobuf",
StatusCode = HttpStatusCode.OK,
Contents = stream => ProtoBuf.Serializer.Serialize(stream, data)
};
};
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment