2 notes &
OpenRasta Codecs
I’ve been messing around a bit with OpenRasta and I’m really impressed with the codecs concept.
Codecs are just things that convert your objects from one thing to another. A normal codec would be CLR object -> html page or CLR object -> json.
So in OpenRasta instead of having the Action/View/WhateverYouCallIt return your HTML page, you have it return an object and the codecs convert it into an HTML page for you.
Your codecs are registered at load/configure time and OpenRasta does all the content negotiation for you. That way you don’t have to worry about output types in your view you can just return a resource and let the codecs do their job.
Registration looks like this:
ConfigureServer(() =>
ResourceSpace.Has.ResourcesOfType<Animal>()
.AtUri(“/animal/{type}”)
.HandledBy<AnimalHandler>()
.AndTranscodedBy<JsonDataContractSerializerCodec>()
.AndBy<XmlSerializerCodec>());
And then your CustomerHandler just has to do something like this:
public Animal Get(string type)
{
return new Animal () {
Name = “Roxy”,
};
}
Some more OpenRasta resources: