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
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
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 /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 /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 / | |
=> | |
200 OK | |
Content-Type: application/hal+json | |
{ | |
"_links": { | |
"self": { "href": "/" }, | |
"urn:tekpub:login": { "href": "/login" } | |
} |
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 / | |
=> | |
200 OK | |
Content-Type: application/hal+json | |
{ | |
"_links": { | |
"self": { "href": "/" }, | |
"urn:tekpub:login": { "href": "/login" } |
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 IWantJSONDammit : DelegatingHandler | |
{ | |
protected override Task<HttpResponseMessage> SendAsync( | |
HttpRequestMessage request, CancellationToken cancellationToken) | |
{ | |
request.Headers.Accept.Clear(); | |
request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); | |
return base.SendAsync(request,cancellationToken); |
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 LoggingFormatterSelector : IFormatterSelector | |
{ | |
private readonly FormatterSelector _FormatterSelector = new FormatterSelector(); | |
public new MediaTypeFormatter SelectReadFormatter(Type type, FormatterContext formatterContext, IEnumerable<MediaTypeFormatter> formatters) | |
{ | |
string descriptFormatterContext = GetDescriptFormatterContext(formatterContext); | |
Console.WriteLine("Selecting Read Formatter for type {0} based on formatter context: {1}", type.Name, descriptFormatterContext); |
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
<?xml version="1.0" encoding="utf-8"?> | |
<resource href="/orders"> | |
<link rel="self" href="/orders"/> | |
<link rel="relatedResource1" href="/orders/relatedResource1"/> | |
<link rel="relatedResource2" href="/orders/relatedResource2"/> |