lots of work to get something like respond_to in rails... after a long reflection I give up... I will separate the APIs from the html in future