Skip to content

Instantly share code, notes, and snippets.

View beyond-code-github's full-sized avatar

Pete Smith beyond-code-github

View GitHub Profile
namespace OwinModulesHelloWorld
{
using Owin;
using Superscribe.Owin;
public class Startup
{
public void Configuration(IAppBuilder app)
{
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5" />
</system.web>
<appSettings>
<add key="owin:HandleAllRequests" value="true" />
<add key="owin:SetCurrentDirectory" value="true" />
</appSettings>
namespace OwinModulesHelloWorld
{
using Superscribe.Owin;
public class HelloWorldModule : SuperscribeOwinModule
{
public HelloWorldModule()
{
this.Get["/"] = _ => "Hello world - OWIN style";
}
@beyond-code-github
beyond-code-github / Startup.cs
Created September 22, 2013 16:38
Startup.cs for Owin Hello world including Json media type handler
namespace OwinModulesHelloWorld
{
using System.IO;
using Newtonsoft.Json;
using Owin;
using Superscribe.Owin;
public class Startup
{
public void Configuration(IAppBuilder app)
@beyond-code-github
beyond-code-github / HelloWorldModule.cs
Created September 22, 2013 16:45
Extended hello world module which will return some 'interesting' json
namespace OwinModulesHelloWorld
{
using Superscribe.Owin;
public class HelloWorldModule : SuperscribeOwinModule
{
public HelloWorldModule()
{
this.Get["/"] = _ => "Hello world - OWIN style";
@beyond-code-github
beyond-code-github / ProductPost.cs
Last active December 23, 2015 16:29
Post handler binding to a product model
this.Post["Products"] = _ =>
{
var product = _.Bind<Product>();
_.StatusCode = 201;
return new { Message = string.Format("Received product {0}", product.Name) };
};
namespace OwinModulesHelloWorld
{
public class Product
{
public int Id { get; set; }
public string Name { get; set; }
public double Price { get; set; }
}
public class IndividualResult<T> {
public bool WasCalculated { get; set; }
public T Result { get; set; }
}
public class CalculatesThings {
private PropertyACalculator<AType> propertyACalculator;
private PropertyBCalculator<BType> propertyBCalculator;
private PropertyCCalculator<CType> propertyCCalculator;
CacheControlHeaderProvider = (request, cfg) =>
{
var matcher = new Regex("/Api/Notifications");
if (matcher.IsMatch(request.RequestUri.ToString()))
{
return null;
}
return new CacheControlHeaderValue
{
public class MailController : ApiController
{
private readonly dynamic[] mail =
{
new { Id = 1, Location = "Inbox", Subject = "value1" },
new { Id = 2, Location = "Inbox", Subject = "value2" },
new { Id = 3, Location = "Inbox", Subject = "value3" },
new { Id = 4, Location = "Deleted", Subject = "value4" },
new { Id = 5, Location = "Sent", Subject = "value5" }
};