Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如何在 Sinatra 中定义当服务器获取 /something 或 /something.html 时将执行的 get?
我以为是...
get '/something*' do end
您可以使用正则表达式来匹配路由,并有一个可选组:
get %r[^/something(?:\.html)?$] do # ... end
Sinatra 似乎有一个启用静态文件匹配的设置:
:static - 启用/禁用静态文件路由
访问 Sinatra 配置设置了解详情