Skip to content

Instantly share code, notes, and snippets.

@danielmarbach
Created November 6, 2012 11:05
Show Gist options
  • Save danielmarbach/4024048 to your computer and use it in GitHub Desktop.
Save danielmarbach/4024048 to your computer and use it in GitHub Desktop.
Simple.Web Tryouts
User-Agent: Fiddler
Accept: image/png
Host: localhost:52649
GET http://localhost:52649/menu
throws UnsupportedMediaTypeException
[UriTemplate("/menu")]
public class GetMenu : IGet, IOutput<List<MenuItem>>
{
public GetMenu()
{
this.Output = new List<MenuItem>
{
new MenuItem { Name = "Latte", Price = 5.50m },
new MenuItem { Name = "Espresso", Price = 4.20m },
};
}
public Status Get()
{
return 200;
}
public List<MenuItem> Output { get; private set; }
}
[UriTemplate("/menu")]
[RespondsWith("image/png")]
public class GetMenuAsImage : IOutputStream
{
public Status Get()
{
return 200;
}
public string ContentType
{
get
{
return "image/png";
}
}
public string ContentDisposition { get; private set; }
public Stream Output
{
get
{
return new MemoryStream();
}
}
}
public class MenuItem
{
public string Name { get; set; }
public decimal Price { get; set; }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment