gpt4 book ai didi

html - 从返回的 grape api 字符串中删除引号

转载 作者:数据小太阳 更新时间:2023-10-29 07:59:25 24 4
gpt4 key购买 nike

我想从我的 grape/rest api 返回原始数据/blob。

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

对于这样的代码:

get 'foo' do
content_type 'text/plain'
"hello world"
end

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

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

3)content_type :txt, '文本/纯文本'在浏览器中给出错误的参数数量错误

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

谢谢。

最佳答案

这是对我有用的:

get 'foo' do
content_type 'text/plain'
env['api.format'] = :binary
body 'Stuff here'
end

The documentation说:

env['api.format'] = :binary # there's no formatter for :binary, data will be returned "as is"

因此,只要您不覆盖 :binary 格式化程序,就应该没问题。

关于html - 从返回的 grape api 字符串中删除引号,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30090614/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com