从返回的葡萄 api 字符串中删除引号

res*_*way 5 html ruby thin ruby-grape

我想从我的葡萄/休息 api 返回原始数据/blob。

我关注了以下线程:https : //github.com/intridea/grape/issues/412

对于像这样的代码:

get 'foo' do
  content_type 'text/plain'
  "hello world"
end
Run Code Online (Sandbox Code Playgroud)

1)我使用:格式'txt' - 我得到了引用文本,如:“hello world”在浏览器上没有错误,curl给出了Content-Type:text/plain但引号没有被删除

2) env['api.format'] = :txt 在浏览器中给出错误

3) content_type :txt, 'text/plain' 在浏览器中给出错误数量的 args

还有其他方法可以解决这个问题吗?

谢谢。

Kev*_*vin 1

根据这个您可以执行以下操作:

class API < Grape::API
  get 'foo' do
    content_type 'text/plain'
    body 'hello world'
  end
end
Run Code Online (Sandbox Code Playgroud)