Rails for Rack 中是否有类似来自 ActionController::Request 的 request_uri 的内容?
我为我的 Rails 编写了一个机架中间件,它根据 REQUEST_URI 是否等于特定字符串来执行某些操作。
然而,我很快发现在我的开发环境中,使用 WEBrick,服务器输入了 REQUEST_URI 的完整 url。在我的生产环境(位于 Heroku 上)上,它的行为与预期一致。
所以我不确定最好的解决方案是什么。 Rails 有一个名为 request_uri 的函数,它可以处理此问题,但由于这种情况正在发生在我的机架中间件中,我认为我无法访问它。另一件事是,这似乎会影响我的开发环境,因此如果最终不会显着降低生产环境的速度,任何解决方案都会更好。
I wrote a rack middleware for my rails that that does something based on the if the REQUEST_URI equals specific string.
However what I quickly found out was in my development environment, which is using WEBrick, is the server puts in the full url for the REQUEST_URI. On my production environment, which is on Heroku, it behaves like expected.
So I'm not sure what the best solution to this is. Rails has a function called request_uri which handles this but since this is happening in my rack middleware I don't think I can access it. Another thing is this just seems to affect my development environment so any solution would be better if it didn't end up slowing down the production environment by any noticeable amount.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是我根据 request_uri
This is what I came up with based on the regular expression found in request_uri