Skip to content

Instantly share code, notes, and snippets.

@dcomartin
Created January 25, 2018 02:48
Show Gist options
  • Save dcomartin/15513ddef59b4ac4ed3df5f30748e9e9 to your computer and use it in GitHub Desktop.
Save dcomartin/15513ddef59b4ac4ed3df5f30748e9e9 to your computer and use it in GitHub Desktop.
public class CustomerModule : BotwinModule
{
public CustomerModule()
{
Get("/customers/{customerId:Guid}", async (request, response, routeData) =>
{
var customer = await CustomerStateService.GetCustomer(Guid.Parse(routeData.Values["customerId"].ToString()));
await response.Negotiate(customer);
});
Post("/customers", async (request, response, _) =>
{
var customerId = Guid.NewGuid();
await CustomerStateService.CreateCustomer(customerId, "CodeOpinion");
response.StatusCode = 201;
response.Headers.Add(new KeyValuePair<string, StringValues>("Location", $"/customers/{customerId}"));
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment