Created
November 6, 2012 11:05
-
-
Save danielmarbach/4024048 to your computer and use it in GitHub Desktop.
Simple.Web Tryouts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
User-Agent: Fiddler | |
Accept: image/png | |
Host: localhost:52649 | |
GET http://localhost:52649/menu | |
throws UnsupportedMediaTypeException |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[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