This file contains hidden or 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
GET /login | |
=> | |
200 OK | |
Content-Type: application/hal+json | |
{"_links": { | |
"self": { "href" : "/Login"}, | |
"urn:tekpub:userhome" : { "href" : "/user/95/home"} | |
}, | |
"Message" : "Welcome Joe" |
This file contains hidden or 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
GET /user/95/home | |
=> | |
200 OK | |
Content-Type: application/hal+json | |
{ "_links": { | |
"self" : { "href" :"/user/95/home" }, | |
"urn:tekpub:allproductions" : { "href" : "/user/95/allproductions", "title" : "All productions" }, | |
"urn:tekpub:newepisodes" : { "href" : "/episodes/new", "title" : "New Episodes" }, | |
"urn:tekpub:productionsbycategory" : { "href" : "/productions{?category}" } | |
"urn:tekpub:categories" : { "href" : "/categories" } |
This file contains hidden or 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
GET /user/95/allproductions | |
=> | |
200 OK | |
Content-Type: application/hal+json | |
{ | |
"_links" : { | |
"self" : { "href" : "/user/95/allproductions" }, | |
}, | |
"name" : "Joe", |
This file contains hidden or 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
GET /production/22 | |
=> | |
200 OK | |
Content-Type: application/hal+json | |
{ | |
"_links" : { | |
"self" : { "href" : "/production/22" }, | |
}, | |
"title" : "Rails runs rings round ReST resource representations", |
This file contains hidden or 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
<apiResults> | |
<resource rel="self" href="/"> | |
<link rel="urn:tekpub:login" href="/Login"/> | |
</resource> | |
<resource rel="self" href="/Login"> | |
<Message>Welcome Joe</Message> | |
<link rel="urn:tekpub:userhome" href="/user/95/home"/> | |
</resource> |
This file contains hidden or 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
[TestMethod] | |
public void ConnegTest() | |
{ | |
var selector = new FormatterSelector(); | |
var response = new HttpResponseMessage(); | |
response.RequestMessage = new HttpRequestMessage(); | |
var headers = response.RequestMessage.Headers; | |
headers.Accept.Add(new MediaTypeWithQualityHeaderValue("text/plain")); | |
headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json",0.8)); |
This file contains hidden or 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
public class PlainTextFormatter : MediaTypeFormatter | |
{ | |
public PlainTextFormatter() | |
{ | |
SupportedMediaTypes.Add(new MediaTypeHeaderValue("text/plain")); | |
} | |
protected override System.Threading.Tasks.Task<object> OnReadFromStreamAsync(Type type, System.IO.Stream stream, HttpContentHeaders contentHeaders, FormatterContext formatterContext) | |
{ | |
return new Task<object>(() => |
This file contains hidden or 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
public class ThroughputMessageHandler : DelegatingHandler | |
{ | |
private readonly ILogger _logger; | |
private Timer _timer; | |
private int _count; | |
public ThroughputMessageHandler(ILogger logger) | |
{ | |
_logger = logger; | |
_count = 0; | |
_timer = new Timer(new TimerCallback(timerCallback),null,1000,1000); |
This file contains hidden or 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
// CustomerController | |
public override Stream Get() { | |
var model = new CustomerModel(Container, _CustomerId); | |
var view = new CustomerDetailView(Container); | |
return view.Render(model); |
This file contains hidden or 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
public class SimpleFormatter<T> : MediaTypeFormatter | |
{ | |
private readonly Action<T,Stream> _write; | |
private readonly Func<Stream,T> _read; | |
public SimpleFormatter(MediaTypeHeaderValue mediatype, Func<Stream,T> read, Action<T,Stream> write) | |
{ | |
_write = write; | |
_read = read; | |
SupportedMediaTypes.Add(mediatype); |