我使用 Roda 编写了一个应用程序。我有一个这样的嵌套路由器:
route 'chats' do |r|
env['warden'].authenticate!
r.is do
@current_user = env['warden'].user
r.get do
# code is here
end
r.post do
# code is here
end
end
r.on :String do |chat_id|
r.is 'messages' do
# code is here
r.get do
# code is here
end
r.post do
# code is here
end
end
end
end
我想将一个大代码块分成两条这样的路线:
route 'chats' do |r|
# code is here
end
route 'chats/:chat_id/messages' do |r, chat_id|
# code is here
end
请帮忙。怎么做才对?