How to split things up in a grape api app?

点点圈 提交于 2019-12-02 20:52:35

The class in post.rb should be Post, not API. Then you can mount the Post API inside class API.

class API < Grape::API
  mount Blog::Post => '/'
end

To avoid confusion I would put Post in a Resources namespace, too or rename it to PostAPI.

I found it not working for path prefix:

mount Blog::Post => '/blog'

doesn't work if you want have prefix the path.

use

namespace :blog do
   mount Blog::Post
end

Hope it helps!

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!