Skip to content

Instantly share code, notes, and snippets.

@asbjornu
Created August 1, 2012 08:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save asbjornu/3224849 to your computer and use it in GitHub Desktop.
Save asbjornu/3224849 to your computer and use it in GitHub Desktop.
OpenRasta resource registration with codecs for three different MIME types and extensions
MediaType json = MediaType.Json.WithQuality(1f);
MediaType xml = MediaType.Xml.WithQuality(0.9f);
MediaType html = MediaType.Html.WithQuality(0.1f);
ResourceSpace.Has
.ResourcesOfType<ResourceBase>()
.WithoutUri
.TranscodedBy<MyXmlCodec>().ForMediaType(xml).ForExtension("xml")
.And.TranscodedBy<MyHtmlCodec>().ForMediaType(html).ForExtension("html")
.And.TranscodedBy<JsonDataContractCodec>().ForMediaType(json).ForExtension("json");
ResourceSpace.Has
// UserListResource inherits ResourceBase
.ResourcesOfType<UserListResource>()
.AtUri("/users")
.HandledBy<UserHandler>();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment