gpt4 book ai didi

ruby - 从 sinatra 中的 before do block 返回不同的值

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

有没有办法在 sinatra 的 before do block 中停止执行并返回不同的值?

before do
# code is here
# I would like to 'return "Message"'
# I would like "/home" to not get called.
end



// rest of the code

get '/home' do

end

最佳答案

before do
halt 401, {'Content-Type' => 'text/plain'}, 'Message!'
end

如果你愿意,你可以只指定状态,这里有状态、标题和正文的例子

关于ruby - 从 sinatra 中的 before do block 返回不同的值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3870808/

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