Skip to content

Instantly share code, notes, and snippets.

@beyond-code-github
Last active December 23, 2015 13:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save beyond-code-github/6641906 to your computer and use it in GitHub Desktop.
Save beyond-code-github/6641906 to your computer and use it in GitHub Desktop.
Model binding and returning a custom status code
namespace WebApiModuleHelloWorld
{
using System.Net;
public class Product
{
public string Name { get; set; }
public double Price { get; set; }
}
public class HelloWorldModule : Superscribe.WebApi.Modules.SuperscribeModule
{
public HelloWorldModule()
{
this.Get["/"] = _ => "Hello World!";
this.Get["Products" / (ʃLong)"Id"] = _ => { throw new NotImplementedException(); };
this.Post["Products"] = _ =>
{
var product = _.Bind<Product>();
// Save product
return HttpStatusCode.Created;
};
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment