Remove quotes from returned string of grapes api
I want to return raw data / blob from my crop / rest api.
I followed the thread: https://github.com/intridea/grape/issues/412
for code like:
get 'foo' do
content_type 'text/plain'
"hello world"
end
1) I used: format 'txt' - I got quoted text like: "hello world" errors in the browser, although, curl gives Content-Type: text / plain, but the quotes are not removed
2) env ['api.format'] =: txt gives error in browser
3) content_type: txt, 'text / plain' gives error in browser wrong number of arguments
Any other ways to fix this?
Thank.
source to share
Using the content_type :txt, 'text/plain'
above method and using the method body
worked for me. Here is my code snippet:
content_type :txt, "text/plain"
desc "ping pong"
get "/ping" do
challenge = params["hub.challenge"]
challenge = "pong" if challenge.to_s.empty?
status 200
body challenge
end
source to share