Creating XML APIs with Grape

I am creating an XML API using the Grape Gem. What is the best way to create XML for API actions? Since Grape does not use standard rail controllers, I cannot use views/../xml.builder . What did you suggest? Maybe there are some recommendations for creating xml api?

+6
source share
2 answers

Sinece there are no answers, I will answer my question. I ended up with modules where I declare different xml responses and include these modules in my Grape API. In API actions, I just call the response methods from these modules. With this approach, my code is clear and divided.

+2
source

It seems to be a sample. Just specify the format to tell the grape your default format.

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

Then add .xml to the end of the request URL.

0
source

Source: https://habr.com/ru/post/923371/


All Articles