将 /api/v1/ url 方案添加到 Rails 应用程序
我正在规划一个主要通过 API 通过客户端应用程序公开的 Web 应用程序。我之前使用过 Rails,所以我将使用它来创建后端。
在规划 API 时,我在 url 方案中添加了一层,如下所示:
http://websitename .com/api/v1/...
将其添加到我的应用程序中的最佳方法是什么?
I'm planning a web app that is exposed primarily through a client application through an API. I've worked with rails before so am going to use this to create the back-end.
Whilst planning the API, I've added in a layer to the url scheme that is as follows:
http://websitename.com/api/v1/...
What is the best way for me to add this to my application?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尝试一下葡萄。它是一个小宝石,可以帮助您设计和编码此类内容。
Give a try to grape. It's a little gem that will help you to design and code this kind of stuff.
我没有像上面提到的那样使用 Grape,但你总是可以在你的路由文件中使用一个范围。
或者
如果你需要的话。
或者
I have not used Grape as mentioned above but you can always go with a scope in your routes file.
OR
if you need it.
OR