Question

I'm building a XML API with the help of the Grape gem. What is the best way to building XML for API actions? Since Grape isn't using standart rails controllers, i can't use views/../xml.builder. What did you suggest? Maybe there are some best practices for building xml api?

Was it helpful?

Solution

Sinece there are no any answers, i will answer my own question. I ended up with modules where are i declare different kind of xml responses and include this modules into my Grape API. In API actions i just calling response methods from this modules. With this approach my code is clear and separated.

OTHER TIPS

It seems to be sample. Just provide format to tell grape your default format

format :xml
content_type :xml, "text/xml"

Then add .xml to the end of request url.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top