Created
August 29, 2012 15:40
-
-
Save benfoster/3514548 to your computer and use it in GitHub Desktop.
Injecting links
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
public class CustomJsonFormatter : JsonMediaTypeFormatter | |
{ | |
public override Task WriteToStreamAsync(Type type, object value, System.IO.Stream writeStream, | |
System.Net.Http.HttpContent content, System.Net.TransportContext transportContext) | |
{ | |
var objectWithLinks = value as IResourceWithLinks; | |
if (objectWithLinks != null) | |
{ | |
objectWithLinks.Links = new[] { new Link { Rel = "Self", Href = "???" } }; | |
} | |
return base.WriteToStreamAsync(type, value, writeStream, content, transportContext); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment