シナリオ
私は Sinatra アプリ
を持っています 特定の名前付きパスに基づいて記事を取得するルートを持っています
# Get Articles for a certain time period
get '/frontpage/:type' do
case params[:type]
when "today"
@news = Article.find(...)
when "yesterday"
@news = Article.find(...)
when "week-ago"
@news = Article.find(...)
when "month-ago"
@news = Article.find(...)
else
not_found
end
erb :frontpage
end
質問たとえば、誰かが代わりに.json を要求した場合、
このルートを維持して .json ページを表示することは可能ですか?"/frontpage/:type"
"/frontpage/:today.json"
"/frontpage/:type"
また
JSON のリクエスト専用に別のルートを作成する方が良いですか?